#40: Support for remote Windows mounts - partial
This commit is contained in:
@@ -4,7 +4,7 @@ const helpers = require('../../helpers');
|
||||
const addListeners = (ipcMain, standardIPCReply) => {
|
||||
ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
|
||||
helpers
|
||||
.getConfig(data.Version, data.Provider)
|
||||
.getConfig(data.Version, data.Provider, data.Remote)
|
||||
.then((data) => {
|
||||
if (data.Code === 0) {
|
||||
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
|
||||
@@ -21,7 +21,7 @@ const addListeners = (ipcMain, standardIPCReply) => {
|
||||
|
||||
ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
|
||||
helpers
|
||||
.getConfigTemplate(data.Version, data.Provider)
|
||||
.getConfigTemplate(data.Version, data.Provider, data.Remote)
|
||||
.then((data) => {
|
||||
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
|
||||
Template: data,
|
||||
@@ -36,7 +36,7 @@ const addListeners = (ipcMain, standardIPCReply) => {
|
||||
const setConfigValue = (i) => {
|
||||
if (i < data.Items.length) {
|
||||
helpers
|
||||
.setConfigValue(data.Items[i].Name, data.Items[i].Value, data.Provider, data.Version)
|
||||
.setConfigValue(data.Items[i].Name, data.Items[i].Value, data.Provider, data.Remote, data.Version)
|
||||
.then(() => {
|
||||
setConfigValue(++i);
|
||||
})
|
||||
|
||||
@@ -16,10 +16,10 @@ const clearManualMountDetection = provider => {
|
||||
}
|
||||
};
|
||||
|
||||
const monitorMount = (sender, provider, version, pid, location) => {
|
||||
const monitorMount = (sender, provider, providerList, version, pid, location) => {
|
||||
manualMountDetection[provider] = setInterval(() => {
|
||||
helpers
|
||||
.detectRepertoryMounts(version)
|
||||
.detectRepertoryMounts(version, providerList)
|
||||
.then(result => {
|
||||
if (result[provider].PID !== pid) {
|
||||
if (result[provider].PID === -1) {
|
||||
@@ -46,7 +46,7 @@ const monitorMount = (sender, provider, version, pid, location) => {
|
||||
|
||||
const unmountAllDrives = () => {
|
||||
// Reset mount states
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
for (const provider of Object.keys(manualMountDetection)) {
|
||||
clearManualMountDetection(provider);
|
||||
expectedUnmount[provider] = true;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ const unmountAllDrives = () => {
|
||||
// Unmount all items
|
||||
for (const i in mountedLocations) {
|
||||
const data = mountedData[mountedLocations[i]];
|
||||
helpers.stopMountProcessSync(data.Version, data.Provider);
|
||||
helpers.stopMountProcessSync(data.Version, data.Provider, data.Remote);
|
||||
}
|
||||
|
||||
mountedLocations = [];
|
||||
@@ -87,7 +87,11 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
|
||||
ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
||||
let driveLetters = {};
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
const providerList = [
|
||||
...Constants.PROVIDER_LIST,
|
||||
data.RemoteMounts,
|
||||
];
|
||||
for (const provider of providerList) {
|
||||
driveLetters[provider] = [];
|
||||
}
|
||||
|
||||
@@ -96,7 +100,7 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
const drive = (String.fromCharCode(i) + ':').toUpperCase();
|
||||
let driveInUse;
|
||||
if (Object.keys(locations).length > 0) {
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
for (const provider of providerList) {
|
||||
driveInUse = locations[provider].startsWith(drive);
|
||||
if (driveInUse)
|
||||
break;
|
||||
@@ -105,7 +109,7 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
if (!driveInUse) {
|
||||
try {
|
||||
if (!fs.existsSync(drive)) {
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
for (const provider of providerList) {
|
||||
driveLetters[provider].push(drive);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +119,7 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
}
|
||||
|
||||
if (Object.keys(locations).length > 0) {
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
for (const provider of providerList) {
|
||||
if (locations[provider].length > 0) {
|
||||
if (!driveLetters[provider].find((driveLetter) => {
|
||||
return driveLetter === locations[provider];
|
||||
@@ -130,7 +134,7 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
const setImage = (locations) => {
|
||||
let driveInUse;
|
||||
if (Object.keys(locations).length > 0) {
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
for (const provider of providerList) {
|
||||
driveInUse = locations[provider].length > 0;
|
||||
if (driveInUse)
|
||||
break;
|
||||
@@ -141,11 +145,11 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
};
|
||||
|
||||
helpers
|
||||
.detectRepertoryMounts(data.Version)
|
||||
.detectRepertoryMounts(data.Version, providerList)
|
||||
.then((results) => {
|
||||
let storageData = {};
|
||||
let locations = {};
|
||||
for (const provider of Constants.PROVIDER_LIST) {
|
||||
for (const provider of providerList) {
|
||||
storageData[provider] = results[provider] ? results[provider] : {
|
||||
Active: false,
|
||||
Location: '',
|
||||
@@ -156,7 +160,7 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
if (storageData[provider].PID !== -1) {
|
||||
expectedUnmount[provider] = false;
|
||||
if (firstMountCheck) {
|
||||
monitorMount(event.sender, provider, data.Version, storageData[provider].PID, storageData[provider].Location);
|
||||
monitorMount(event.sender, provider, providerList, data.Version, storageData[provider].PID, storageData[provider].Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,8 +197,9 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
} else {
|
||||
mountedLocations.push(data.Location);
|
||||
mountedData[data.Location] = {
|
||||
Version: data.Version,
|
||||
Provider: data.Provider,
|
||||
Remote: data.Remote,
|
||||
Version: data.Version,
|
||||
};
|
||||
const errorHandler = (pid, error) => {
|
||||
if (mountedLocations.indexOf(data.Location) !== -1) {
|
||||
@@ -206,15 +211,17 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
Expected: expectedUnmount[data.Provider],
|
||||
Location: data.Location,
|
||||
Provider: data.Provider,
|
||||
Remote: data.Remote,
|
||||
}, error || Error(data.Provider + ' Unmounted'));
|
||||
};
|
||||
helpers
|
||||
.executeMount(data.Version, data.Provider, data.Location, data.NoConsoleSupported, (error, pid) => {
|
||||
.executeMount(data.Version, data.Provider, data.Remote, data.Location, data.NoConsoleSupported, (error, pid) => {
|
||||
errorHandler(pid, error);
|
||||
})
|
||||
.then(() => {
|
||||
standardIPCReply(event, Constants.IPC_Mount_Drive_Reply, {
|
||||
Provider: data.Provider,
|
||||
Remote: data.Remote,
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -233,7 +240,7 @@ const addListeners = (ipcMain, setTrayImage, standardIPCReply) => {
|
||||
|
||||
expectedUnmount[data.Provider] = true;
|
||||
helpers
|
||||
.stopMountProcess(data.Version, data.Provider)
|
||||
.stopMountProcess(data.Version, data.Provider, data.Remote)
|
||||
.then(result => {
|
||||
console.log(result);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user