mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 23:49:55 +02:00
Ask if user want to update home content when available
This commit is contained in:
parent
5f45e62333
commit
cb4d526dcf
1 changed files with 131 additions and 54 deletions
|
@ -486,6 +486,76 @@ function updateTrayMenu(serverState) {
|
||||||
|
|
||||||
const httpStatusPort = 60332;
|
const httpStatusPort = 60332;
|
||||||
|
|
||||||
|
function deleteResourceDirectories() {
|
||||||
|
const dsResourceDirectory = getDomainServerClientResourcesDirectory();
|
||||||
|
try {
|
||||||
|
fs.removeSync(dsResourceDirectory);
|
||||||
|
console.log("Deleted directory " + dsResourceDirectory);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
const acResourceDirectory = getAssignmentClientResourcesDirectory();
|
||||||
|
try {
|
||||||
|
fs.removeSync(acResourceDirectory);
|
||||||
|
console.log("Deleted directory " + acResourceDirectory);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteResourceDirectoriesAndRestart() {
|
||||||
|
homeServer.stop();
|
||||||
|
deleteResourceDirectories();
|
||||||
|
maybeInstallDefaultContentSet(onContentLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkNewContent() {
|
||||||
|
// Start downloading content set
|
||||||
|
var req = request.head({
|
||||||
|
url: "http://cachefly.highfidelity.com/home.tgz"
|
||||||
|
}, function (error, response, body) {
|
||||||
|
if (error === null) {
|
||||||
|
var localContent = Date.parse(userConfig.get('homeContentLastModified'));
|
||||||
|
var remoteContent = Date.parse(response.headers['last-modified']);
|
||||||
|
|
||||||
|
var shouldUpdate = isNaN(localContent) || (!isNaN(remoteContent) && (remoteContent > localContent));
|
||||||
|
|
||||||
|
var wantDebug = false;
|
||||||
|
if (wantDebug) {
|
||||||
|
console.log('Last Modified: ' + response.headers['last-modified']);
|
||||||
|
console.log(localContent + " " + remoteContent + " " + shouldUpdate + " " + new Date());
|
||||||
|
console.log("Remote content is " + (shouldUpdate ? "newer" : "older") + " that local content.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldUpdate) {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
type: 'question',
|
||||||
|
buttons: ['Yes', 'No'],
|
||||||
|
title: 'New home content',
|
||||||
|
message: 'A newer version of the home content set is available.\nDo you wish to update?'
|
||||||
|
}, function(idx) {
|
||||||
|
if (idx === 0) {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
type: 'question',
|
||||||
|
buttons: ['Yes', 'No'],
|
||||||
|
title: 'Are you sure?',
|
||||||
|
message: 'This action will delete your current sandbox content.\nDo you wish to continue?'
|
||||||
|
}, function(idx) {
|
||||||
|
if (idx === 0 && homeServer) {
|
||||||
|
deleteResourceDirectoriesAndRestart();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// They don't want to update, mark content set as current
|
||||||
|
userConfig.set('homeContentLastModified', new Date());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function maybeInstallDefaultContentSet(onComplete) {
|
function maybeInstallDefaultContentSet(onComplete) {
|
||||||
// Check for existing data
|
// Check for existing data
|
||||||
const acResourceDirectory = getAssignmentClientResourcesDirectory();
|
const acResourceDirectory = getAssignmentClientResourcesDirectory();
|
||||||
|
@ -517,6 +587,8 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
if (userHasExistingACData || userHasExistingDSData) {
|
if (userHasExistingACData || userHasExistingDSData) {
|
||||||
console.log("User has existing data, suppressing downloader");
|
console.log("User has existing data, suppressing downloader");
|
||||||
onComplete();
|
onComplete();
|
||||||
|
|
||||||
|
checkNewContent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,6 +600,7 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
return console.error(err)
|
return console.error(err)
|
||||||
}
|
}
|
||||||
console.log('Copied home content over to: ' + getRootHifiDataDirectory());
|
console.log('Copied home content over to: ' + getRootHifiDataDirectory());
|
||||||
|
userConfig.set('homeContentLastModified', new Date());
|
||||||
onComplete();
|
onComplete();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -607,6 +680,7 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
req.pipe(gunzip).pipe(tar.extract(getRootHifiDataDirectory())).on('error', extractError).on('finish', function(){
|
req.pipe(gunzip).pipe(tar.extract(getRootHifiDataDirectory())).on('error', extractError).on('finish', function(){
|
||||||
// response and decompression complete, return
|
// response and decompression complete, return
|
||||||
console.log("Finished unarchiving home content set");
|
console.log("Finished unarchiving home content set");
|
||||||
|
userConfig.set('homeContentLastModified', new Date());
|
||||||
sendStateUpdate('complete');
|
sendStateUpdate('complete');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -663,26 +737,7 @@ for (var key in trayIcons) {
|
||||||
|
|
||||||
const notificationIcon = path.join(__dirname, '../resources/console-notification.png');
|
const notificationIcon = path.join(__dirname, '../resources/console-notification.png');
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
function onContentLoaded() {
|
||||||
// initialization and is ready to create browser windows.
|
|
||||||
app.on('ready', function() {
|
|
||||||
|
|
||||||
if (app.dock) {
|
|
||||||
// hide the dock icon on OS X
|
|
||||||
app.dock.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create tray icon
|
|
||||||
tray = new Tray(trayIcons[ProcessGroupStates.STOPPED]);
|
|
||||||
tray.setToolTip('High Fidelity Sandbox');
|
|
||||||
|
|
||||||
tray.on('click', function() {
|
|
||||||
tray.popUpContextMenu(tray.menu);
|
|
||||||
});
|
|
||||||
|
|
||||||
updateTrayMenu(ProcessGroupStates.STOPPED);
|
|
||||||
|
|
||||||
maybeInstallDefaultContentSet(function() {
|
|
||||||
maybeShowSplash();
|
maybeShowSplash();
|
||||||
|
|
||||||
if (buildInfo.releaseType == 'PRODUCTION') {
|
if (buildInfo.releaseType == 'PRODUCTION') {
|
||||||
|
@ -735,5 +790,27 @@ app.on('ready', function() {
|
||||||
// start the home server
|
// start the home server
|
||||||
homeServer.start();
|
homeServer.start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// This method will be called when Electron has finished
|
||||||
|
// initialization and is ready to create browser windows.
|
||||||
|
app.on('ready', function() {
|
||||||
|
|
||||||
|
if (app.dock) {
|
||||||
|
// hide the dock icon on OS X
|
||||||
|
app.dock.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create tray icon
|
||||||
|
tray = new Tray(trayIcons[ProcessGroupStates.STOPPED]);
|
||||||
|
tray.setToolTip('High Fidelity Sandbox');
|
||||||
|
|
||||||
|
tray.on('click', function() {
|
||||||
|
tray.popUpContextMenu(tray.menu);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateTrayMenu(ProcessGroupStates.STOPPED);
|
||||||
|
|
||||||
|
maybeInstallDefaultContentSet(onContentLoaded);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue