aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-02-28 20:37:30 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-02-29 02:34:52 +0000
commitbf35cb18afadc8499e1f7254f89e0196e3cd95b7 (patch)
tree5f5dff21e38cbe7bbeb9e2b8a664603c8cdf1fff
parentd84129429a7553211fffd956fc2c05675aa03a06 (diff)
downloadluarocks-bf35cb18afadc8499e1f7254f89e0196e3cd95b7.tar.gz
luarocks-bf35cb18afadc8499e1f7254f89e0196e3cd95b7.tar.bz2
luarocks-bf35cb18afadc8499e1f7254f89e0196e3cd95b7.zip
feat(fs): drop stale lock files (older than 1 hour)
This feature is dependent on lfs.
-rw-r--r--src/luarocks/fs/lua.lua10
1 files changed, 9 insertions, 1 deletions
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
301 301
302function fs_lua.lock_access(dirname, force) 302function fs_lua.lock_access(dirname, force)
303 fs.make_dir(dirname) 303 fs.make_dir(dirname)
304 local lockfile = dir.path(dirname, "lockfile.lfs")
305
306 -- drop stale lock, older than 1 hour
307 local age = fs.file_age(lockfile)
308 if age > 3600 and age < math.huge then
309 force = true
310 end
311
304 if force then 312 if force then
305 os.remove(dir.path(dirname, "lockfile.lfs")) 313 os.remove(lockfile)
306 end 314 end
307 return lfs.lock_dir(dirname) 315 return lfs.lock_dir(dirname)
308end 316end