diff options
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index d7334733..f1513820 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -311,6 +311,12 @@ function tools.is_superuser() | |||
311 | return fs.current_user() == "root" | 311 | return fs.current_user() == "root" |
312 | end | 312 | end |
313 | 313 | ||
314 | local lock_mt = { | ||
315 | __gc = function(lock) | ||
316 | fs.unlock_access(lock) | ||
317 | end | ||
318 | } | ||
319 | |||
314 | function tools.lock_access(dirname, force) | 320 | function tools.lock_access(dirname, force) |
315 | local ok, err = fs.make_dir(dirname) | 321 | local ok, err = fs.make_dir(dirname) |
316 | if not ok then | 322 | if not ok then |
@@ -336,10 +342,12 @@ function tools.lock_access(dirname, force) | |||
336 | local force_flag = force and " -f" or "" | 342 | local force_flag = force and " -f" or "" |
337 | 343 | ||
338 | if fs.execute(vars.LN .. force_flag, tempfile, lockfile) then | 344 | if fs.execute(vars.LN .. force_flag, tempfile, lockfile) then |
339 | return { | 345 | local lock = { |
340 | tempfile = tempfile, | 346 | tempfile = tempfile, |
341 | lockfile = lockfile, | 347 | lockfile = lockfile, |
342 | } | 348 | } |
349 | setmetatable(lock, lock_mt) | ||
350 | return lock | ||
343 | else | 351 | else |
344 | return nil, "File exists" -- same message as luafilesystem | 352 | return nil, "File exists" -- same message as luafilesystem |
345 | end | 353 | end |