summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-12-15 23:16:47 +0100
committerDaniel Weipert <code@drogueronin.de>2022-01-10 13:28:28 +0100
commit61eb4a652ff35fd6b4b29645dc2412690083e610 (patch)
treea8dd69e3798f0d28192cd09af913325c3377062b
parent3d29da167e1e0071b4cde3700c825c5c6e40448d (diff)
Fix and catch copyFile path above local_path error
-rw-r--r--lua/rclone.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/lua/rclone.lua b/lua/rclone.lua
index 27809bf..308f06c 100644
--- a/lua/rclone.lua
+++ b/lua/rclone.lua
@@ -248,7 +248,14 @@ local function copyFile(options)
-- build relative 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_relative = local_file_path:gsub(local_path:gsub('([^%w])', '%%%1'), '')
+ local local_path_pattern = local_path:gsub('([^%w])', '%%%1')
+
+ if local_file_path:find(local_path_pattern) == nil then
+ print('Local path not in file path')
+ return
+ end
+
+ 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
local cmd =