#22: Display error if daemon version is too low
This commit is contained in:
@@ -278,6 +278,44 @@ ipcMain.on(Constants.IPC_Browse_Directory + '_sync', (event, data) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
helpers
|
||||||
|
.checkDaemonVersion(dataDirectory, data.Version, data.StorageType)
|
||||||
|
.then(code => {
|
||||||
|
standardIPCReply(event, Constants.IPC_Check_Daemon_Version_Reply, {
|
||||||
|
Valid: (code === 0),
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(e=> {
|
||||||
|
standardIPCReply(event, Constants.IPC_Check_Daemon_Version_Reply, {
|
||||||
|
Valid: false,
|
||||||
|
}, e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on(Constants.IPC_Check_Daemon_Version + '_sync', (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
helpers
|
||||||
|
.checkDaemonVersion(dataDirectory, data.Version, data.StorageType)
|
||||||
|
.then(code => {
|
||||||
|
event.returnValue = {
|
||||||
|
data: {
|
||||||
|
Valid: (code === 0),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
event.returnValue = {
|
||||||
|
data: {
|
||||||
|
Error: e.toString(),
|
||||||
|
Success: false,
|
||||||
|
Valid: false
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Check_Dependency_Installed, (event, data) => {
|
ipcMain.on(Constants.IPC_Check_Dependency_Installed, (event, data) => {
|
||||||
try {
|
try {
|
||||||
const exists = fs.lstatSync(data.File).isFile();
|
const exists = fs.lstatSync(data.File).isFile();
|
||||||
|
|||||||
@@ -95,10 +95,12 @@ class MountItems extends IPCContainer {
|
|||||||
let allowAction = true;
|
let allowAction = true;
|
||||||
if (mount) {
|
if (mount) {
|
||||||
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
|
||||||
|
Directory: this.props.directory,
|
||||||
StorageType: storageType,
|
StorageType: storageType,
|
||||||
Version: this.props.version
|
Version: this.props.version
|
||||||
});
|
});
|
||||||
if (result.Success) {
|
if (result.Success) {
|
||||||
|
if (result.Valid) {
|
||||||
if (this.props.platform !== 'win32') {
|
if (this.props.platform !== 'win32') {
|
||||||
result = this.sendSyncRequest(Constants.IPC_Check_Mount_Location, {
|
result = this.sendSyncRequest(Constants.IPC_Check_Mount_Location, {
|
||||||
Location: location,
|
Location: location,
|
||||||
@@ -108,6 +110,10 @@ class MountItems extends IPCContainer {
|
|||||||
this.props.errorHandler(result.Error.toString());
|
this.props.errorHandler(result.Error.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
allowAction = false;
|
||||||
|
this.props.errorHandler("Incompatible " + storageType + " daemon. Please upgrade " + storageType);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
allowAction = false;
|
allowAction = false;
|
||||||
this.props.errorHandler(result.Error.toString());
|
this.props.errorHandler(result.Error.toString());
|
||||||
|
|||||||
@@ -16,6 +16,34 @@ const tryParse = (j, def) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.checkDaemonVersion = (directory, version, storageType) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const processOptions = {
|
||||||
|
detached: true,
|
||||||
|
shell: false,
|
||||||
|
windowsHide: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
|
const args = [];
|
||||||
|
args.push('-cv');
|
||||||
|
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
|
||||||
|
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const process = new spawn(command, args, processOptions);
|
||||||
|
|
||||||
|
process.on('error', err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('exit', code => {
|
||||||
|
resolve(code);
|
||||||
|
});
|
||||||
|
process.unref();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
module.exports.createSignatureFiles = (signature, publicKey) => {
|
module.exports.createSignatureFiles = (signature, publicKey) => {
|
||||||
const fileName1 = RandomString.generate({
|
const fileName1 = RandomString.generate({
|
||||||
length: 12,
|
length: 12,
|
||||||
|
|||||||
Reference in New Issue
Block a user