detect builds by checksum and purge all old code

This commit is contained in:
2026-08-20 19:11:39 -07:00
parent 7c5455e2d2
commit 64194d9ea4
2 changed files with 20 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ class Patcher {
const versionFile = path.join(this.appDataPath, 'version.json');
if (fs.existsSync(versionFile)) {
try {
return JSON.parse(fs.readFileSync(versionFile, 'utf8')).version;
return JSON.parse(fs.readFileSync(versionFile, 'utf8')).version || '0.0.0';
} catch (e) {
return '0.0.0';
}
@@ -21,6 +21,18 @@ class Patcher {
return '0.0.0';
}
getCurrentSha() {
const versionFile = path.join(this.appDataPath, 'version.json');
if (fs.existsSync(versionFile)) {
try {
return JSON.parse(fs.readFileSync(versionFile, 'utf8')).sha256 || null;
} catch (e) {
return null;
}
}
return null;
}
bridgeCredentials(credentialManager) {
const encryptedPath = path.join(this.appDataPath, 'encrypted-credentials.json');
if (!fs.existsSync(encryptedPath)) {
@@ -39,14 +51,14 @@ class Patcher {
return true;
}
saveCurrentVersion(version) {
saveCurrentVersion(version, sha256 = null) {
const versionFile = path.join(this.appDataPath, 'version.json');
fs.mkdirSync(this.appDataPath, { recursive: true });
fs.writeFileSync(versionFile, JSON.stringify({ version }, null, 2), 'utf8');
fs.writeFileSync(versionFile, JSON.stringify({ version, sha256 }, null, 2), 'utf8');
}
purgeOldCode() {
const dirs = ['frontend', 'player', 'stream-api'];
const dirs = ['frontend', 'player', 'stream-api', 'auth-proxy', 'config'];
for (const dir of dirs) {
const fullPath = path.join(this.appDataPath, dir);
if (fs.existsSync(fullPath)) {