[projects/pld-ftp-admin] ftpiod: lock a tree once whatever it is called
arekm
arekm at pld-linux.org
Tue Oct 27 10:56:07 CET 2026
commit 469e9dff27af97f1b4f94492070cf77dc73ad936
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Tue Oct 27 01:06:56 2026 +0100
ftpiod: lock a tree once whatever it is called
Locks were keyed by the name as given, so PLD, PLD/, ./PLD and a symlink
to the tree were four locks, and two tools could work on one tree at
once. The name is now resolved to the tree's real directory first, for
locking and unlocking alike; pfa-dump-locks shows that name.
modules/cmds.py | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/modules/cmds.py b/modules/cmds.py
index 64163da..9231f66 100644
--- a/modules/cmds.py
+++ b/modules/cmds.py
@@ -1,6 +1,7 @@
# vi: ts=8 sts=4 sw=4 et
import hashlib
+import os
import time
import common
@@ -39,7 +40,14 @@ def parse(con):
raise BailOut()
# TODO: log this
+def lock_key(arg):
+ """One lock per tree, whatever it is called: PLD, PLD/, ./PLD or a symlink to it."""
+ # pfa-lintpkg locks rpmlint:TREE
+ prefix, colon, tree = arg.rpartition(':')
+ return prefix + colon + os.path.relpath(os.path.realpath(config.ftp_dir + tree), os.path.realpath(config.ftp_dir))
+
def lock(con, arg, hard):
+ arg = lock_key(arg)
if arg not in locks:
locks[arg]={'hard': hard, 'name': con.name, 'time': int(time.time())}
con.sock.send(bytearray("OK", encoding='utf-8'))
@@ -49,6 +57,7 @@ def lock(con, arg, hard):
con.sock.send(bytearray("SOFT", encoding='utf-8')) # Soft lock - try in a second or two
def cmd_unlock(con, arg):
+ arg = lock_key(arg)
if arg in locks:
del locks[arg]
con.sock.send(bytearray("OK", encoding='utf-8'))
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/9da94db07ea316d05f5466d10ac4e10519ad6d46
More information about the pld-cvs-commit
mailing list