v1.8.79: fix updater — hardcoded Gitea API URL for frozen exe
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -62,8 +62,11 @@ def _version_newer(remote: str, local: str) -> bool:
|
|||||||
return _parse_version(remote) > _parse_version(local)
|
return _parse_version(remote) > _parse_version(local)
|
||||||
|
|
||||||
|
|
||||||
def _gitea_api(endpoint: str) -> Optional[dict]:
|
_GITEA_API_BASE = "https://git.sensey24.ru/api/v1/repos/aibot777/server-manager"
|
||||||
"""Call Gitea API. Reads credentials from git remote 'sensey'."""
|
|
||||||
|
|
||||||
|
def _get_auth_headers() -> dict:
|
||||||
|
"""Try to get Gitea auth headers from git remote. Returns empty dict on failure."""
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["git", "remote", "get-url", "sensey"],
|
["git", "remote", "get-url", "sensey"],
|
||||||
@@ -71,42 +74,23 @@ def _gitea_api(endpoint: str) -> Optional[dict]:
|
|||||||
creationflags=_SUBPROCESS_FLAGS,
|
creationflags=_SUBPROCESS_FLAGS,
|
||||||
)
|
)
|
||||||
remote_url = result.stdout.strip()
|
remote_url = result.stdout.strip()
|
||||||
except Exception:
|
m = re.match(r"https://([^:]+):([^@]+)@", remote_url)
|
||||||
# Frozen exe: no git available, try reading from embedded config
|
if m:
|
||||||
remote_url = ""
|
user, password = m.groups()
|
||||||
|
return {
|
||||||
if not remote_url:
|
|
||||||
# Fallback: try common remote names
|
|
||||||
for name in ["origin"]:
|
|
||||||
try:
|
|
||||||
result = subprocess.run(
|
|
||||||
["git", "remote", "get-url", name],
|
|
||||||
capture_output=True, text=True, cwd=PROJECT_DIR,
|
|
||||||
creationflags=_SUBPROCESS_FLAGS,
|
|
||||||
)
|
|
||||||
if result.returncode == 0:
|
|
||||||
remote_url = result.stdout.strip()
|
|
||||||
break
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if not remote_url:
|
|
||||||
return None
|
|
||||||
|
|
||||||
m = re.match(r"https://([^:]+):([^@]+)@([^/]+)/(.+?)(?:\.git)?$", remote_url)
|
|
||||||
if not m:
|
|
||||||
return None
|
|
||||||
|
|
||||||
user, password, host, repo_path = m.groups()
|
|
||||||
url = f"https://{host}/api/v1/repos/{repo_path}/{endpoint}"
|
|
||||||
|
|
||||||
headers = {
|
|
||||||
"Authorization": "Basic " + base64.b64encode(
|
"Authorization": "Basic " + base64.b64encode(
|
||||||
f"{user}:{password}".encode()
|
f"{user}:{password}".encode()
|
||||||
).decode(),
|
).decode()
|
||||||
}
|
}
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return {}
|
||||||
|
|
||||||
req = urllib.request.Request(url, headers=headers, method="GET")
|
|
||||||
|
def _gitea_api(endpoint: str) -> Optional[dict]:
|
||||||
|
"""Call Gitea API. Tries git remote auth first, falls back to public API."""
|
||||||
|
url = f"{_GITEA_API_BASE}/{endpoint}"
|
||||||
|
req = urllib.request.Request(url, headers=_get_auth_headers(), method="GET")
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(req, timeout=15) as resp:
|
with urllib.request.urlopen(req, timeout=15) as resp:
|
||||||
return json.loads(resp.read().decode())
|
return json.loads(resp.read().decode())
|
||||||
@@ -219,21 +203,7 @@ class UpdateChecker:
|
|||||||
def download_update(self, url: str, progress_cb=None) -> Optional[str]:
|
def download_update(self, url: str, progress_cb=None) -> Optional[str]:
|
||||||
"""Download update binary to temp dir. Returns path or None."""
|
"""Download update binary to temp dir. Returns path or None."""
|
||||||
try:
|
try:
|
||||||
# Get auth headers
|
headers = _get_auth_headers()
|
||||||
result = subprocess.run(
|
|
||||||
["git", "remote", "get-url", "sensey"],
|
|
||||||
capture_output=True, text=True, cwd=PROJECT_DIR,
|
|
||||||
creationflags=_SUBPROCESS_FLAGS,
|
|
||||||
)
|
|
||||||
remote_url = result.stdout.strip()
|
|
||||||
headers = {}
|
|
||||||
m = re.match(r"https://([^:]+):([^@]+)@", remote_url)
|
|
||||||
if m:
|
|
||||||
user, password = m.groups()
|
|
||||||
headers["Authorization"] = "Basic " + base64.b64encode(
|
|
||||||
f"{user}:{password}".encode()
|
|
||||||
).decode()
|
|
||||||
|
|
||||||
req = urllib.request.Request(url, headers=headers, method="GET")
|
req = urllib.request.Request(url, headers=headers, method="GET")
|
||||||
resp = urllib.request.urlopen(req, timeout=120)
|
resp = urllib.request.urlopen(req, timeout=120)
|
||||||
|
|
||||||
|
|||||||
BIN
releases/ServerManager-v1.8.79-win-x64.exe
Normal file
BIN
releases/ServerManager-v1.8.79-win-x64.exe
Normal file
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
"""Version info for ServerManager."""
|
"""Version info for ServerManager."""
|
||||||
|
|
||||||
__version__ = "1.8.78"
|
__version__ = "1.8.79"
|
||||||
__app_name__ = "ServerManager"
|
__app_name__ = "ServerManager"
|
||||||
__author__ = "aibot777"
|
__author__ = "aibot777"
|
||||||
__description__ = "Desktop GUI for managing remote servers"
|
__description__ = "Desktop GUI for managing remote servers"
|
||||||
|
|||||||
Reference in New Issue
Block a user