#40: Support for remote Windows mounts - partial

This commit is contained in:
2019-10-05 17:17:24 -05:00
parent 38825f970a
commit 9be55984bc
13 changed files with 268 additions and 185 deletions

View File

@@ -72,12 +72,13 @@ class MountItems extends IPCContainer {
if (!this.state.DisplayRetry) {
this.props.setMountsBusy(true);
this.sendRequest(Constants.IPC_Detect_Mounts, {
RemoteMounts: this.props.RemoteMounts,
Version: this.props.InstalledVersion,
});
}
};
displayRetryMount = (provider, mountLocation, msg) => {
displayRetryMount = (provider, remote, mountLocation, msg) => {
if (!this.state.RetryItems[provider]) {
let retryItems = {
...this.state.RetryItems
@@ -104,7 +105,7 @@ class MountItems extends IPCContainer {
const retrySeconds = retryItems[provider].RetrySeconds - 1;
if (retrySeconds === 0) {
this.cancelRetryMount(provider, () => {
this.handleMountUnMount(provider, true, mountLocation);
this.handleMountUnMount(provider, remote,true, mountLocation);
});
} else {
retryItems[provider].RetrySeconds = retrySeconds;
@@ -139,16 +140,20 @@ class MountItems extends IPCContainer {
this.props.setProviderState(provider, state);
};
handleMountUnMount = (provider, mount, location) => {
handleMountUnMount = (provider, remote, mount, location) => {
console.log(provider, remote, mount, location);
if (!location || (location.trim().length === 0)) {
this.props.notifyError('Mount location is not set');
} else {
let allowAction = true;
if (mount) {
let result = this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
Provider: provider,
Version: this.props.InstalledVersion
}).data;
let result = remote ?
{Valid: true, Success: true} :
this.sendSyncRequest(Constants.IPC_Check_Daemon_Version, {
Provider: provider,
Remote: remote,
Version: this.props.InstalledVersion
}).data;
if (result.Success) {
if (result.Valid) {
if (this.props.Platform !== 'win32') {
@@ -163,11 +168,11 @@ class MountItems extends IPCContainer {
} else {
allowAction = false;
if ((result.Code === new Uint32Array([-1])[0]) || (result.Code === new Uint8Array([-1])[0])) {
this.displayRetryMount(provider, location, 'Failed to connect to ' + provider + ' daemon');
this.displayRetryMount(provider, remote, location, 'Failed to connect to ' + provider + ' daemon');
} else if ((result.Code === new Uint32Array([-3])[0]) || (result.Code === new Uint8Array([-3])[0])) {
this.displayRetryMount(provider, location, 'Incompatible ' + provider + ' daemon. Please upgrade ' + provider + '.');
this.displayRetryMount(provider, remote, location, 'Incompatible ' + provider + ' daemon. Please upgrade ' + provider + '.');
} else {
this.displayRetryMount(provider, location, 'Version check failed: ' + result.Error);
this.displayRetryMount(provider, remote, location, 'Version check failed: ' + result.Error);
}
}
} else {
@@ -175,7 +180,7 @@ class MountItems extends IPCContainer {
if (this.props.Platform === 'win32') {
this.props.notifyError('Failed to launch repertory. Please install Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019.');
} else {
this.displayRetryMount(provider, location, 'Version check failed: ' + result.Error);
this.displayRetryMount(provider, remote, location, 'Version check failed: ' + result.Error);
}
}
}
@@ -189,12 +194,14 @@ class MountItems extends IPCContainer {
Location: location,
NoConsoleSupported: this.props.noConsoleSupported,
Provider: provider,
Remote: remote,
Version: this.props.InstalledVersion,
});
} else {
this.sendRequest(Constants.IPC_Unmount_Drive, {
Location: location,
Provider: provider,
Remote: remote,
Version: this.props.InstalledVersion,
});
}
@@ -202,11 +209,19 @@ class MountItems extends IPCContainer {
}
};
getProviderList = () => {
return [
...Constants.PROVIDER_LIST,
...this.props.RemoteMounts,
];
};
onDetectMountsReply = (event, arg) => {
if (!this.state.DisplayRetry && arg.data.Success) {
let mountsBusy = false;
let mountStates = {};
for (const provider of Constants.PROVIDER_LIST) {
for (const provider of this.getProviderList()) {
const mountState = {
AllowMount: true,
DriveLetters: (arg.data.DriveLetters[provider]),
@@ -238,11 +253,11 @@ class MountItems extends IPCContainer {
this.props.ProviderState[provider].AutoMount &&
!mountStates[provider].Mounted &&
(location.length > 0)) {
this.handleMountUnMount(provider, true, location);
this.handleMountUnMount(provider, this.props.RemoteMounts.includes(provider),true, location);
}
};
for (const provider of Constants.PROVIDER_LIST) {
for (const provider of this.getProviderList()) {
updateMountLocation(arg.data, provider);
}
@@ -259,7 +274,7 @@ class MountItems extends IPCContainer {
onUnmountDriveReply = (event, arg) => {
if (arg && arg.data && !arg.data.Expected && arg.data.Location && this.props.ProviderState[arg.data.Provider].AutoRestart) {
this.displayRetryMount(arg.data.Provider, arg.data.Location);
this.displayRetryMount(arg.data.Provider, arg.data.Remote, arg.data.Location);
} else {
this.detectMounts();
}
@@ -296,6 +311,12 @@ class MountItems extends IPCContainer {
}
let items = [];
if (this.props.remoteSupported) {
items.push(<AddRemoteMount key={'mi_' + items.length}/>);
items.push(<div key={'di_' + items.length}
style={{paddingTop: '4px'}} />)
}
for (const provider of Constants.PROVIDER_LIST) {
items.push((
<MountItem allowConfig={this.props.allowConfig}
@@ -319,13 +340,15 @@ class MountItems extends IPCContainer {
changed={e => this.handleMountLocationChanged(provider, e.target.value)}
clicked={this.handleMountUnMount}
key={'mi_' + items.length}
provider={provider}/>
provider={provider}
remote/>
));
items.push(<div key={'di_' + items.length}
style={{paddingTop: '4px'}}/>)
}
items.push(<AddRemoteMount key={'mia_' + items.length + 1}/>);
if (this.props.RemoteMounts.length > 0) {
items.splice(items.length - 1, 1);
}
} else {
items.splice(items.length - 1, 1)
}