refs #4974 Solved bug app open error

This commit is contained in:
Guillermo Bonet 2023-02-07 19:02:05 +01:00
parent cc79a76120
commit 1a6f22e539
1 changed files with 51 additions and 45 deletions

View File

@ -405,58 +405,64 @@ var App = {
);
},
onVersionRequest: function(err, res) {
if (err)
throw new Error ('Version could not be retrieved: '+ err.message +': ');
try {
if (err)
throw new Error ('Version could not be retrieved: '+ err.message +': ');
var lastVersion;
// Checks if it's already open
if (this.fso.fileExists(this.lockFile))
try {
this.fso.deleteFile(this.lockFile);
lastVersion = res.version;
} catch (e) {
throw new Error(_('Application it\'s already open'));
}
var lastVersion;
// Checks if it's already open
if (this.fso.fileExists(this.lockFile))
try {
this.fso.deleteFile(this.lockFile);
lastVersion = res.version;
} catch (e) {
throw new Error(_('Application it\'s already open'));
}
// Checks if MDB exists
if (!this.fso.fileExists(this.mdbFile))
lastVersion = res.version;
// If it's abnormaly bigger, maybe is corrupted, so force download
if (!lastVersion) {
var file = this.fso.getFile(this.mdbFile);
if (file.size > Conf.maxCorruptSize * 1024 * 1024)
// Checks if MDB exists
if (!this.fso.fileExists(this.mdbFile))
lastVersion = res.version;
// Obtains the local version number from the MDB file
var localVersion = this.mdbGetValue(
'SELECT Version FROM tblVariables',
'Version', parseInt
);
if (!localVersion)
localVersion = false;
// If it's abnormaly bigger, maybe is corrupted, so force download
if (!lastVersion) {
var file = this.fso.getFile(this.mdbFile);
if (file.size > Conf.maxCorruptSize * 1024 * 1024)
lastVersion = res.version;
// Determines if should download
!localVersion || res.version === false || localVersion != res.version
? lastVersion = res.version
: lastVersion = null;
// Obtains the local version number from the MDB file
var localVersion = this.mdbGetValue(
'SELECT Version FROM tblVariables',
'Version', parseInt
);
if (!localVersion)
localVersion = false;
// Determines if should download
!localVersion || res.version === false || localVersion != res.version
? lastVersion = res.version
: lastVersion = null;
}
// Check if there is a new version, and if there is, download it
if (lastVersion) {
this.disableUi(true, _('Updating'));
var remoteFile = lastVersion
? '.archive/'+ this.module +'/'+ lastVersion +'.7z'
: this.module +'.7z?'+ new Date().getTime();
remoteFile = Conf.cdnURL +'/'+ remoteFile;
var request = new ActiveXObject('MSXML2.XMLHTTP.6.0');
request.open('GET', remoteFile, true);
request.onreadystatechange = function() {
App.onRequestReady(request);
};
request.send();
} else
App.openMdb();
}
catch (err) {
this.catchError(err);
}
// Check if there is a new version, and if there is, download it
if (lastVersion) {
this.disableUi(true, _('Updating'));
var remoteFile = lastVersion
? '.archive/'+ this.module +'/'+ lastVersion +'.7z'
: this.module +'.7z?'+ new Date().getTime();
remoteFile = Conf.cdnURL +'/'+ remoteFile;
var request = new ActiveXObject('MSXML2.XMLHTTP.6.0');
request.open('GET', remoteFile, true);
request.onreadystatechange = function() {
App.onRequestReady(request);
};
request.send();
} else
App.openMdb();
},
mdbGetValue: function(query, field, parseFn) {
var value;