mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
sfx: cooperate better with other instances
This commit is contained in:
parent
0e87f35547
commit
e86c719575
|
@ -268,25 +268,25 @@ def unpack():
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
for fn in u8(os.listdir(top)):
|
||||||
|
if fn.startswith(name) and fn != withpid:
|
||||||
|
try:
|
||||||
|
old = opj(top, fn)
|
||||||
|
if time.time() - os.path.getmtime(old) > 86400:
|
||||||
|
shutil.rmtree(old)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.symlink(mine, final)
|
os.symlink(mine, final)
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
os.rename(mine, final)
|
os.rename(mine, final)
|
||||||
|
return final
|
||||||
except:
|
except:
|
||||||
msg("reloc fail,", mine)
|
msg("reloc fail,", mine)
|
||||||
return mine
|
|
||||||
|
|
||||||
for fn in u8(os.listdir(top)):
|
return mine
|
||||||
if fn.startswith(name) and fn not in [name, withpid]:
|
|
||||||
try:
|
|
||||||
old = opj(top, fn)
|
|
||||||
if time.time() - os.path.getmtime(old) > 10:
|
|
||||||
shutil.rmtree(old)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return final
|
|
||||||
|
|
||||||
|
|
||||||
def get_payload():
|
def get_payload():
|
||||||
|
@ -377,7 +377,6 @@ def run(tmp, j2):
|
||||||
|
|
||||||
fd = os.open(tmp, os.O_RDONLY)
|
fd = os.open(tmp, os.O_RDONLY)
|
||||||
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
tmp = os.readlink(tmp) # can't flock a symlink, even with O_NOFOLLOW
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if not WINDOWS:
|
if not WINDOWS:
|
||||||
msg("\033[31mflock:", repr(ex))
|
msg("\033[31mflock:", repr(ex))
|
||||||
|
@ -436,7 +435,7 @@ def main():
|
||||||
|
|
||||||
# skip 0
|
# skip 0
|
||||||
|
|
||||||
tmp = unpack()
|
tmp = os.path.realpath(unpack())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from jinja2 import __version__ as j2
|
from jinja2 import __version__ as j2
|
||||||
|
|
Loading…
Reference in a new issue