diff --git a/lib/config/config-schema.json b/lib/config/config-schema.json index d46f9f2..4939eb3 100644 --- a/lib/config/config-schema.json +++ b/lib/config/config-schema.json @@ -93,6 +93,20 @@ "type": "boolean", "default": true, "order": 9 + }, + "defaultDownloadPath": { + "title": "Default download path", + "description": "Default download path for folders and files, if empty - current system user Download folder.", + "type": "string", + "default": "", + "order": 10 + }, + "defaultUploadPath": { + "title": "Default upload path", + "description": "Default upload path for folders and files, if empty - current system user Desktop folder.", + "type": "string", + "default": "", + "order": 11 } }, "order": 5 @@ -106,8 +120,7 @@ "description": "Specifies the key at which the search is to be used.", "type": "string", "default": "Filename", - "enum": [ - { + "enum": [{ "value": "Filename", "description": "Filename" }, diff --git a/lib/ftp-remote-edit.js b/lib/ftp-remote-edit.js index 0f1893f..4c0d0d7 100644 --- a/lib/ftp-remote-edit.js +++ b/lib/ftp-remote-edit.js @@ -268,39 +268,39 @@ class FtpRemoteEdit { detail: reasonForRequest + '\n-------------------------------\n' + caution, dismissable: true, buttons: [{ - text: 'Always', - onDidClick: () => { - buttondismiss = true; - notif.dismiss(); - addToWhiteList(Storage.getPassword(), reasonForRequest); - resolve(root.config); - } - }, - { - text: 'Accept', - onDidClick: () => { - buttondismiss = true; - notif.dismiss(); - resolve(root.config); - } - }, - { - text: 'Decline', - onDidClick: () => { - buttondismiss = true; - notif.dismiss(); - reject('userdeclined'); - } - }, - { - text: 'Never', - onDidClick: () => { - buttondismiss = true; - notif.dismiss(); - addToBlackList(Storage.getPassword(), reasonForRequest); - reject('userdeclined'); - } - }, + text: 'Always', + onDidClick: () => { + buttondismiss = true; + notif.dismiss(); + addToWhiteList(Storage.getPassword(), reasonForRequest); + resolve(root.config); + } + }, + { + text: 'Accept', + onDidClick: () => { + buttondismiss = true; + notif.dismiss(); + resolve(root.config); + } + }, + { + text: 'Decline', + onDidClick: () => { + buttondismiss = true; + notif.dismiss(); + reject('userdeclined'); + } + }, + { + text: 'Never', + onDidClick: () => { + buttondismiss = true; + notif.dismiss(); + addToBlackList(Storage.getPassword(), reasonForRequest); + reject('userdeclined'); + } + }, ] }); @@ -628,7 +628,7 @@ class FtpRemoteEdit { if (!FileSystem.existsSync(fullLocalPath)) { createLocalPath(fullLocalPath); } - } catch (err) { } + } catch (err) {} directory.getConnector().existsDirectory(fullRelativePath).then((result) => { showMessage('Directory ' + relativePath.trim() + ' already exists', 'error'); @@ -864,7 +864,7 @@ class FtpRemoteEdit { if (FileSystem.existsSync(fullLocalPath)) { FileSystem.unlinkSync(fullLocalPath); } - } catch (err) { } + } catch (err) {} file.parent.select(); file.destroy(); @@ -1189,11 +1189,12 @@ class FtpRemoteEdit { destObject = destObject.parent; } + let defaultPath = atom.config.get('ftp-remote-edit.tree.defaultUploadPath') || Electron.remote.app.getPath("desktop"); let srcPath = null; let destPath = null; if (type == 'file') { - Electron.remote.dialog.showOpenDialog(null, { title: 'Select file(s) for upload...', defaultPath: Electron.remote.app.getPath("desktop"), buttonLabel: 'Upload', properties: ['openFile', 'multiSelections', 'showHiddenFiles'] }, (filePaths, bookmarks) => { + Electron.remote.dialog.showOpenDialog(null, { title: 'Select file(s) for upload...', defaultPath: defaultPath, buttonLabel: 'Upload', properties: ['openFile', 'multiSelections', 'showHiddenFiles'] }, (filePaths, bookmarks) => { if (filePaths) { Promise.all(filePaths.map((filePath) => { srcPath = filePath; @@ -1207,7 +1208,7 @@ class FtpRemoteEdit { } }); } else if (type == 'directory') { - Electron.remote.dialog.showOpenDialog(null, { title: 'Select directory for upload...', defaultPath: Electron.remote.app.getPath("desktop"), buttonLabel: 'Upload', properties: ['openDirectory', 'showHiddenFiles'] }, (directoryPaths, bookmarks) => { + Electron.remote.dialog.showOpenDialog(null, { title: 'Select directory for upload...', defaultPath: defaultPath, buttonLabel: 'Upload', properties: ['openDirectory', 'showHiddenFiles'] }, (directoryPaths, bookmarks) => { if (directoryPaths) { directoryPaths.forEach((directoryPath, index) => { srcPath = directoryPath; @@ -1231,12 +1232,14 @@ class FtpRemoteEdit { if (selected.length === 0) return; if (!Storage.hasPassword()) return; + let defaultPath = atom.config.get('ftp-remote-edit.tree.defaultDownloadPath') || Electron.remote.app.getPath("downloads"); + if (selected.view().is('.file')) { let file = selected.view(); if (file) { const srcPath = normalize(file.getPath(true) + file.name); - Electron.remote.dialog.showSaveDialog(null, { defaultPath: Electron.remote.app.getPath("downloads") + "/" + file.name }, (destPath) => { + Electron.remote.dialog.showSaveDialog(null, { defaultPath: defaultPath + "/" + file.name }, (destPath) => { if (destPath) { self.downloadFile(file.getRoot(), srcPath, destPath, { filesize: file.size }).then(() => { showMessage('File has been downloaded to ' + destPath, 'success'); @@ -1251,7 +1254,7 @@ class FtpRemoteEdit { if (directory) { const srcPath = normalize(directory.getPath(true)); - Electron.remote.dialog.showSaveDialog(null, { defaultPath: Electron.remote.app.getPath("downloads") + "/" + directory.name }, (destPath) => { + Electron.remote.dialog.showSaveDialog(null, { defaultPath: defaultPath + "/" + directory.name }, (destPath) => { if (destPath) { self.downloadDirectory(directory.getRoot(), srcPath, destPath).then(() => { showMessage('Directory has been downloaded to ' + destPath, 'success'); @@ -1266,7 +1269,7 @@ class FtpRemoteEdit { if (server) { const srcPath = normalize(server.getPath(true)); - Electron.remote.dialog.showSaveDialog(null, { defaultPath: Electron.remote.app.getPath("downloads") + "/" }, (destPath) => { + Electron.remote.dialog.showSaveDialog(null, { defaultPath: defaultPath + "/" }, (destPath) => { if (destPath) { self.downloadDirectory(server, srcPath, destPath).then(() => { showMessage('Directory has been downloaded to ' + destPath, 'success'); @@ -1873,7 +1876,7 @@ class FtpRemoteEdit { editor.saveObject.removeClass('open'); }); - } catch (err) { } + } catch (err) {} }).catch((err) => { showMessage(err.message, 'error'); });