Switch to VERSION file for update detection (works for zip downloads)

This commit is contained in:
Reditus committed 2026-05-12 03:45:43 +01:00
1 parent 5d5c6a8780
commit e9fb72ed02
2 files changed
+11 -5

No files matched your search

+1
View File
@@ -0,0 +1 @@
5d5c6a8
+10 -5
View File
@@ -68,15 +68,15 @@ class UpdateService:
data = json.loads(resp.read().decode())
self._latest_sha = data['commit']['sha']
# Try to get current SHA from .git/refs/heads/main
git_ref = os.path.join(self.project_root, '.git', 'refs', 'heads', 'main')
if os.path.exists(git_ref):
with open(git_ref) as f:
# Get current SHA from VERSION file (works for zip downloads)
version_file = os.path.join(self.project_root, 'VERSION')
if os.path.exists(version_file):
with open(version_file) as f:
self._current_sha = f.read().strip()
self._update_available = self._latest_sha != self._current_sha
self._last_check = time.time()
logger.info(f"Update check: {'available' if self._update_available else 'up to date'}")
logger.info(f"Update check: {'available' if self._update_available else 'up to date'} (local={self._current_sha}, remote={self._latest_sha})")
except Exception as e:
logger.debug(f"Update check error: {e}")
@@ -161,6 +161,11 @@ class UpdateService:
# Cleanup temp
shutil.rmtree(temp_dir, ignore_errors=True)
# Update VERSION file to match new commit
version_file = os.path.join(self.project_root, 'VERSION')
with open(version_file, 'w') as f:
f.write(self._latest_sha + '\n')
self._update_status = f"Update applied! {files_updated} files updated. Restarting..."
self._update_available = False