mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
windows: safeguard against parallel deletes
st_ino is valid for NTFS on python3, good enough
This commit is contained in:
parent
b9d0c8536b
commit
aa3a971961
|
@ -2092,9 +2092,13 @@ def wunlink(log: "NamedLogger", abspath: str, flags: dict[str, Any]) -> bool:
|
||||||
if chill < 0.001:
|
if chill < 0.001:
|
||||||
chill = 0.1
|
chill = 0.1
|
||||||
|
|
||||||
|
ino = 0
|
||||||
t0 = now = time.time()
|
t0 = now = time.time()
|
||||||
for attempt in range(90210):
|
for attempt in range(90210):
|
||||||
try:
|
try:
|
||||||
|
if ino and os.stat(bpath).st_ino != ino:
|
||||||
|
log("inode changed; aborting delete")
|
||||||
|
return False
|
||||||
os.unlink(bpath)
|
os.unlink(bpath)
|
||||||
if attempt:
|
if attempt:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
@ -2108,6 +2112,8 @@ def wunlink(log: "NamedLogger", abspath: str, flags: dict[str, Any]) -> bool:
|
||||||
if now - t0 > maxtime or attempt == 90209:
|
if now - t0 > maxtime or attempt == 90209:
|
||||||
raise
|
raise
|
||||||
if not attempt:
|
if not attempt:
|
||||||
|
if not PY2:
|
||||||
|
ino = os.stat(bpath).st_ino
|
||||||
t = "delete failed (err.%d); retrying for %d sec: %s"
|
t = "delete failed (err.%d); retrying for %d sec: %s"
|
||||||
log(t % (ex.errno, maxtime + 0.99, abspath))
|
log(t % (ex.errno, maxtime + 0.99, abspath))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue