mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
up2k-hasher robustness:
webdav clients tend to upload and then immediately delete files to test for write-access and available disk space, so don't crash and burn when that happens
This commit is contained in:
parent
32ab65d7cb
commit
bac733113c
|
@ -3921,45 +3921,58 @@ class Up2k(object):
|
||||||
self.n_hashq -= 1
|
self.n_hashq -= 1
|
||||||
# self.log("hashq {}".format(self.n_hashq))
|
# self.log("hashq {}".format(self.n_hashq))
|
||||||
|
|
||||||
ptop, vtop, rd, fn, ip, at, usr, skip_xau = self.hashq.get()
|
task = self.hashq.get()
|
||||||
# self.log("hashq {} pop {}/{}/{}".format(self.n_hashq, ptop, rd, fn))
|
if len(task) != 8:
|
||||||
if "e2d" not in self.flags[ptop]:
|
raise Exception("invalid hash task")
|
||||||
continue
|
|
||||||
|
|
||||||
abspath = djoin(ptop, rd, fn)
|
try:
|
||||||
self.log("hashing " + abspath)
|
if not self._hash_t(task):
|
||||||
inf = bos.stat(abspath)
|
|
||||||
if not inf.st_size:
|
|
||||||
wark = up2k_wark_from_metadata(
|
|
||||||
self.salt, inf.st_size, int(inf.st_mtime), rd, fn
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
hashes = self._hashlist_from_file(abspath)
|
|
||||||
if not hashes:
|
|
||||||
return
|
return
|
||||||
|
except Exception as ex:
|
||||||
|
self.log("failed to hash %s: %s" % (task, ex), 1)
|
||||||
|
|
||||||
wark = up2k_wark_from_hashlist(self.salt, inf.st_size, hashes)
|
def _hash_t(self, task: tuple[str, str, str, str, str, float, str, bool]) -> bool:
|
||||||
|
ptop, vtop, rd, fn, ip, at, usr, skip_xau = task
|
||||||
|
# self.log("hashq {} pop {}/{}/{}".format(self.n_hashq, ptop, rd, fn))
|
||||||
|
if "e2d" not in self.flags[ptop]:
|
||||||
|
return True
|
||||||
|
|
||||||
with self.mutex:
|
abspath = djoin(ptop, rd, fn)
|
||||||
self.idx_wark(
|
self.log("hashing " + abspath)
|
||||||
self.flags[ptop],
|
inf = bos.stat(abspath)
|
||||||
rd,
|
if not inf.st_size:
|
||||||
fn,
|
wark = up2k_wark_from_metadata(
|
||||||
inf.st_mtime,
|
self.salt, inf.st_size, int(inf.st_mtime), rd, fn
|
||||||
inf.st_size,
|
)
|
||||||
ptop,
|
else:
|
||||||
vtop,
|
hashes = self._hashlist_from_file(abspath)
|
||||||
wark,
|
if not hashes:
|
||||||
"",
|
return False
|
||||||
usr,
|
|
||||||
ip,
|
|
||||||
at,
|
|
||||||
skip_xau,
|
|
||||||
)
|
|
||||||
|
|
||||||
if at and time.time() - at > 30:
|
wark = up2k_wark_from_hashlist(self.salt, inf.st_size, hashes)
|
||||||
with self.rescan_cond:
|
|
||||||
self.rescan_cond.notify_all()
|
with self.mutex:
|
||||||
|
self.idx_wark(
|
||||||
|
self.flags[ptop],
|
||||||
|
rd,
|
||||||
|
fn,
|
||||||
|
inf.st_mtime,
|
||||||
|
inf.st_size,
|
||||||
|
ptop,
|
||||||
|
vtop,
|
||||||
|
wark,
|
||||||
|
"",
|
||||||
|
usr,
|
||||||
|
ip,
|
||||||
|
at,
|
||||||
|
skip_xau,
|
||||||
|
)
|
||||||
|
|
||||||
|
if at and time.time() - at > 30:
|
||||||
|
with self.rescan_cond:
|
||||||
|
self.rescan_cond.notify_all()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def hash_file(
|
def hash_file(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Reference in a new issue