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)
|
||||
|
||||
|
||||
def _gitea_api(endpoint: str) -> Optional[dict]:
|
||||
"""Call Gitea API. Reads credentials from git remote 'sensey'."""
|
||||
_GITEA_API_BASE = "https://git.sensey24.ru/api/v1/repos/aibot777/server-manager"
|
||||
|
||||
|
||||
def _get_auth_headers() -> dict:
|
||||
"""Try to get Gitea auth headers from git remote. Returns empty dict on failure."""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["git", "remote", "get-url", "sensey"],
|
||||
@@ -71,42 +74,23 @@ def _gitea_api(endpoint: str) -> Optional[dict]:
|
||||
creationflags=_SUBPROCESS_FLAGS,
|
||||
)
|
||||
remote_url = result.stdout.strip()
|
||||
m = re.match(r"https://([^:]+):([^@]+)@", remote_url)
|
||||
if m:
|
||||
user, password = m.groups()
|
||||
return {
|
||||
"Authorization": "Basic " + base64.b64encode(
|
||||
f"{user}:{password}".encode()
|
||||
).decode()
|
||||
}
|
||||
except Exception:
|
||||
# Frozen exe: no git available, try reading from embedded config
|
||||
remote_url = ""
|
||||
pass
|
||||
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(
|
||||
f"{user}:{password}".encode()
|
||||
).decode(),
|
||||
}
|
||||
|
||||
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:
|
||||
with urllib.request.urlopen(req, timeout=15) as resp:
|
||||
return json.loads(resp.read().decode())
|
||||
@@ -219,21 +203,7 @@ class UpdateChecker:
|
||||
def download_update(self, url: str, progress_cb=None) -> Optional[str]:
|
||||
"""Download update binary to temp dir. Returns path or None."""
|
||||
try:
|
||||
# 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()
|
||||
|
||||
headers = _get_auth_headers()
|
||||
req = urllib.request.Request(url, headers=headers, method="GET")
|
||||
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__ = "1.8.78"
|
||||
__version__ = "1.8.79"
|
||||
__app_name__ = "ServerManager"
|
||||
__author__ = "aibot777"
|
||||
__description__ = "Desktop GUI for managing remote servers"
|
||||
|
||||
Reference in New Issue
Block a user