mirror of
https://github.com/overte-org/overte.git
synced 2025-04-07 21:33:48 +02:00
Incomplete sandbox content updates are now removed and reperformed
This commit is contained in:
parent
15a5464bab
commit
9fa21fc79f
1 changed files with 24 additions and 1 deletions
|
@ -101,6 +101,10 @@ function getApplicationDataDirectory() {
|
|||
return path.join(getRootHifiDataDirectory(), '/Server Console');
|
||||
}
|
||||
|
||||
// Update lock filepath
|
||||
const UPDATER_LOCK_FILENAME = ".updating";
|
||||
const UPDATER_LOCK_FULL_PATH = getRootHifiDataDirectory() + "/" + UPDATER_LOCK_FILENAME;
|
||||
|
||||
// Configure log
|
||||
global.log = require('electron-log');
|
||||
const logFile = getApplicationDataDirectory() + '/log.txt';
|
||||
|
@ -630,11 +634,22 @@ function checkNewContent() {
|
|||
userConfig.save(configPath);
|
||||
}
|
||||
});
|
||||
} else if (fs.existsSync(UPDATER_LOCK_FULL_PATH)) {
|
||||
backupResourceDirectoriesAndRestart();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function removeIncompleteUpdate(acResourceDirectory, dsResourceDirectory) {
|
||||
if (fs.existsSync(UPDATER_LOCK_FULL_PATH)) {
|
||||
log.debug('Removing incomplete content update files before copying new update');
|
||||
fs.emptyDirSync(dsResourceDirectory);
|
||||
fs.emptyDirSync(acResourceDirectory);
|
||||
} else {
|
||||
fs.ensureFileSync(UPDATER_LOCK_FULL_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
function maybeInstallDefaultContentSet(onComplete) {
|
||||
// Check for existing data
|
||||
|
@ -673,7 +688,11 @@ function maybeInstallDefaultContentSet(onComplete) {
|
|||
}
|
||||
|
||||
log.debug("Found contentPath:" + argv.contentPath);
|
||||
|
||||
if (argv.contentPath) {
|
||||
// check if we're updating a data folder whose update is incomplete
|
||||
removeIncompleteUpdate(acResourceDirectory, dsResourceDirectory);
|
||||
|
||||
fs.copy(argv.contentPath, getRootHifiDataDirectory(), function (err) {
|
||||
if (err) {
|
||||
log.debug('Could not copy home content: ' + err);
|
||||
|
@ -682,12 +701,12 @@ function maybeInstallDefaultContentSet(onComplete) {
|
|||
log.debug('Copied home content over to: ' + getRootHifiDataDirectory());
|
||||
userConfig.set('homeContentLastModified', new Date());
|
||||
userConfig.save(configPath);
|
||||
fs.removeSync(UPDATER_LOCK_FULL_PATH);
|
||||
onComplete();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Show popup
|
||||
var window = new BrowserWindow({
|
||||
icon: appIcon,
|
||||
|
@ -718,6 +737,9 @@ function maybeInstallDefaultContentSet(onComplete) {
|
|||
|
||||
var aborted = false;
|
||||
|
||||
// check if we're updating a data folder whose update is incomplete
|
||||
removeIncompleteUpdate(acResourceDirectory, dsResourceDirectory);
|
||||
|
||||
// Start downloading content set
|
||||
var req = progress(request.get({
|
||||
url: HOME_CONTENT_URL
|
||||
|
@ -763,6 +785,7 @@ function maybeInstallDefaultContentSet(onComplete) {
|
|||
log.debug("Finished unarchiving home content set");
|
||||
userConfig.set('homeContentLastModified', new Date());
|
||||
userConfig.save(configPath);
|
||||
fs.removeSync(UPDATER_LOCK_FULL_PATH);
|
||||
sendStateUpdate('complete');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue