Likely solution to lua 5.1 and 5.2 bug.

This commit is contained in:
Brian Sobulefsky 2022-08-24 00:17:41 -07:00 committed by Emmanuel Lepage Vallee
parent e8584f47b4
commit 9d9fedf945
1 changed files with 4 additions and 4 deletions

View File

@ -40,7 +40,7 @@ local function get_default_dir()
local home_dir = os.getenv("HOME")
if home_dir then
home_dir = string.gsub(home_dir, '/*$', '/') .. 'Images/'
home_dir = string.gsub(home_dir, '/*$', '/', 1) .. 'Images/'
if gears.filesystem.dir_writable(home_dir) then
return home_dir
end
@ -70,15 +70,15 @@ local function check_directory(directory)
-- is arguably unexpected behavior.
if string.find(directory, "^~/") then
directory = string.gsub(directory, "^~/",
string.gsub(os.getenv("HOME"), "/*$", "/"))
string.gsub(os.getenv("HOME"), "/*$", "/", 1))
elseif string.find(directory, "^[^/]") then
directory = string.gsub(os.getenv("HOME"), "/*$", "/") .. directory
directory = string.gsub(os.getenv("HOME"), "/*$", "/", 1) .. directory
end
print("After first sanitation -- " .. directory)
-- Assure that we return exactly one trailing slash
directory = string.gsub(directory, '/*$', '/')
directory = string.gsub(directory, '/*$', '/', 1)
print("After second sanitation -- " .. directory)
if gears.filesystem.dir_writable(directory) then