From bf35cb18afadc8499e1f7254f89e0196e3cd95b7 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 28 Feb 2024 20:37:30 -0300 Subject: feat(fs): drop stale lock files (older than 1 hour) This feature is dependent on lfs. --- src/luarocks/fs/lua.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index f64b0c18..5c369648 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -301,8 +301,16 @@ end function fs_lua.lock_access(dirname, force) fs.make_dir(dirname) + local lockfile = dir.path(dirname, "lockfile.lfs") + + -- drop stale lock, older than 1 hour + local age = fs.file_age(lockfile) + if age > 3600 and age < math.huge then + force = true + end + if force then - os.remove(dir.path(dirname, "lockfile.lfs")) + os.remove(lockfile) end return lfs.lock_dir(dirname) end -- cgit v1.2.3-55-g6feb