mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-21 17:45:40 -05:00
detect builds by checksum and purge all old code
This commit is contained in:
6
main.js
6
main.js
@@ -563,7 +563,7 @@ button:active {
|
|||||||
|
|
||||||
patcher.applyPatches(replacementsConfig);
|
patcher.applyPatches(replacementsConfig);
|
||||||
patcher.bridgeCredentials(serviceManager.credentialManager);
|
patcher.bridgeCredentials(serviceManager.credentialManager);
|
||||||
patcher.saveCurrentVersion(release.version);
|
patcher.saveCurrentVersion(release.version, release.sha256);
|
||||||
|
|
||||||
fs.unlinkSync(tempZipPath);
|
fs.unlinkSync(tempZipPath);
|
||||||
downloadSuccess = true;
|
downloadSuccess = true;
|
||||||
@@ -580,12 +580,14 @@ button:active {
|
|||||||
try {
|
try {
|
||||||
const isFirstRun = !patcher.verifyExtraction();
|
const isFirstRun = !patcher.verifyExtraction();
|
||||||
const localVersion = patcher.getCurrentVersion();
|
const localVersion = patcher.getCurrentVersion();
|
||||||
|
const localSha = patcher.getCurrentSha();
|
||||||
|
|
||||||
const release = await updateClient.checkForUpdates();
|
const release = await updateClient.checkForUpdates();
|
||||||
|
const hasUpdate = release.version !== localVersion || (release.sha256 && release.sha256 !== localSha);
|
||||||
|
|
||||||
if (isFirstRun) {
|
if (isFirstRun) {
|
||||||
await installBuild(release);
|
await installBuild(release);
|
||||||
} else if (release.version !== localVersion) {
|
} else if (hasUpdate) {
|
||||||
const choice = await showUpdatePrompt(localVersion, release.version);
|
const choice = await showUpdatePrompt(localVersion, release.version);
|
||||||
if (choice === 'install') {
|
if (choice === 'install') {
|
||||||
await installBuild(release);
|
await installBuild(release);
|
||||||
|
|||||||
20
patcher.js
20
patcher.js
@@ -13,7 +13,7 @@ class Patcher {
|
|||||||
const versionFile = path.join(this.appDataPath, 'version.json');
|
const versionFile = path.join(this.appDataPath, 'version.json');
|
||||||
if (fs.existsSync(versionFile)) {
|
if (fs.existsSync(versionFile)) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(fs.readFileSync(versionFile, 'utf8')).version;
|
return JSON.parse(fs.readFileSync(versionFile, 'utf8')).version || '0.0.0';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return '0.0.0';
|
return '0.0.0';
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,18 @@ class Patcher {
|
|||||||
return '0.0.0';
|
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) {
|
bridgeCredentials(credentialManager) {
|
||||||
const encryptedPath = path.join(this.appDataPath, 'encrypted-credentials.json');
|
const encryptedPath = path.join(this.appDataPath, 'encrypted-credentials.json');
|
||||||
if (!fs.existsSync(encryptedPath)) {
|
if (!fs.existsSync(encryptedPath)) {
|
||||||
@@ -39,14 +51,14 @@ class Patcher {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCurrentVersion(version) {
|
saveCurrentVersion(version, sha256 = null) {
|
||||||
const versionFile = path.join(this.appDataPath, 'version.json');
|
const versionFile = path.join(this.appDataPath, 'version.json');
|
||||||
fs.mkdirSync(this.appDataPath, { recursive: true });
|
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() {
|
purgeOldCode() {
|
||||||
const dirs = ['frontend', 'player', 'stream-api'];
|
const dirs = ['frontend', 'player', 'stream-api', 'auth-proxy', 'config'];
|
||||||
for (const dir of dirs) {
|
for (const dir of dirs) {
|
||||||
const fullPath = path.join(this.appDataPath, dir);
|
const fullPath = path.join(this.appDataPath, dir);
|
||||||
if (fs.existsSync(fullPath)) {
|
if (fs.existsSync(fullPath)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user