summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/rclone.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/lua/rclone.lua b/lua/rclone.lua
index 51346e7..0f94916 100644
--- a/lua/rclone.lua
+++ b/lua/rclone.lua
@@ -342,9 +342,23 @@ local function downloadFile(options)
local local_path = prepare_cmd_local_path(config)
- -- build relative path to file for local and remote
+ -- build path to file for local and remote
local Path = require('plenary.path')
- local local_file_path = Path:new(vim.fn.expand('%')):absolute()
+ local local_file_path = ''
+
+ if options['directory'] then
+ local_file_path = Path:new(vim.fn.expand(options['directory']))
+
+ if local_file_path:exists() ~= true then
+ print('Directory "' .. local_file_path:absolute() .. '" to download to missing')
+ return
+ end
+
+ local_file_path = local_file_path:absolute()
+ else
+ local_file_path = Path:new(vim.fn.expand('%')):absolute()
+ end
+
local local_path_pattern = vim.pesc(local_path)
if local_file_path:find(local_path_pattern) == nil then
@@ -355,6 +369,10 @@ local function downloadFile(options)
local local_file_path_relative = local_file_path:gsub(local_path_pattern, '')
local local_file_path_relative_parent = Path:new(local_file_path_relative):parent().filename
+ if options['directory'] then
+ local_file_path_relative_parent = local_file_path_relative
+ end
+
local cmd =
'rclone copy ' ..
build_cmd_remote_path(config, remote) .. local_file_path_relative .. ' ' ..