mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
avoid hashing busy uploads during rescan
This commit is contained in:
parent
e82f176289
commit
0d9567575a
|
@ -95,7 +95,7 @@ class Up2k(object):
|
||||||
|
|
||||||
if ANYWIN:
|
if ANYWIN:
|
||||||
# usually fails to set lastmod too quickly
|
# usually fails to set lastmod too quickly
|
||||||
self.lastmod_q = Queue()
|
self.lastmod_q = []
|
||||||
thr = threading.Thread(target=self._lastmodder, name="up2k-lastmod")
|
thr = threading.Thread(target=self._lastmodder, name="up2k-lastmod")
|
||||||
thr.daemon = True
|
thr.daemon = True
|
||||||
thr.start()
|
thr.start()
|
||||||
|
@ -583,9 +583,11 @@ class Up2k(object):
|
||||||
self.pp.msg = "a{} {}".format(self.pp.n, cdir)
|
self.pp.msg = "a{} {}".format(self.pp.n, cdir)
|
||||||
histpath = self.asrv.vfs.histtab[top]
|
histpath = self.asrv.vfs.histtab[top]
|
||||||
ret = 0
|
ret = 0
|
||||||
seen_files = {}
|
seen_files = {} # != inames; files-only for dropcheck
|
||||||
g = statdir(self.log_func, not self.args.no_scandir, False, cdir)
|
g = statdir(self.log_func, not self.args.no_scandir, False, cdir)
|
||||||
for iname, inf in sorted(g):
|
g = sorted(g)
|
||||||
|
inames = {x[0]: 1 for x in g}
|
||||||
|
for iname, inf in g:
|
||||||
abspath = os.path.join(cdir, iname)
|
abspath = os.path.join(cdir, iname)
|
||||||
if rei and rei.search(abspath):
|
if rei and rei.search(abspath):
|
||||||
continue
|
continue
|
||||||
|
@ -612,6 +614,17 @@ class Up2k(object):
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
rp = rp.replace("\\", "/").strip("/")
|
rp = rp.replace("\\", "/").strip("/")
|
||||||
|
|
||||||
|
if rp.endswith(".PARTIAL") and time.time() - lmod < 60:
|
||||||
|
# rescan during upload
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not sz and (
|
||||||
|
"{}.PARTIAL".format(iname) in inames
|
||||||
|
or ".{}.PARTIAL".format(iname) in inames
|
||||||
|
):
|
||||||
|
# placeholder for unfinished upload
|
||||||
|
continue
|
||||||
|
|
||||||
rd, fn = rp.rsplit("/", 1) if "/" in rp else ["", rp]
|
rd, fn = rp.rsplit("/", 1) if "/" in rp else ["", rp]
|
||||||
sql = "select w, mt, sz from up where rd = ? and fn = ?"
|
sql = "select w, mt, sz from up where rd = ? and fn = ?"
|
||||||
try:
|
try:
|
||||||
|
@ -1109,7 +1122,8 @@ class Up2k(object):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def _orz(self, db_path):
|
def _orz(self, db_path):
|
||||||
return sqlite3.connect(db_path, check_same_thread=False).cursor()
|
timeout = int(max(self.args.srch_time, 5) * 1.2)
|
||||||
|
return sqlite3.connect(db_path, timeout, check_same_thread=False).cursor()
|
||||||
# x.set_trace_callback(trace)
|
# x.set_trace_callback(trace)
|
||||||
|
|
||||||
def _open_db(self, db_path):
|
def _open_db(self, db_path):
|
||||||
|
@ -1478,7 +1492,7 @@ class Up2k(object):
|
||||||
if lmod and (not linked or SYMTIME):
|
if lmod and (not linked or SYMTIME):
|
||||||
times = (int(time.time()), int(lmod))
|
times = (int(time.time()), int(lmod))
|
||||||
if ANYWIN:
|
if ANYWIN:
|
||||||
self.lastmod_q.put([dst, 0, times])
|
self.lastmod_q.append([dst, 0, times])
|
||||||
else:
|
else:
|
||||||
bos.utime(dst, times, False)
|
bos.utime(dst, times, False)
|
||||||
|
|
||||||
|
@ -1575,7 +1589,7 @@ class Up2k(object):
|
||||||
times = (int(time.time()), int(job["lmod"]))
|
times = (int(time.time()), int(job["lmod"]))
|
||||||
if ANYWIN:
|
if ANYWIN:
|
||||||
a = [dst, job["size"], times]
|
a = [dst, job["size"], times]
|
||||||
self.lastmod_q.put(a)
|
self.lastmod_q.append(a)
|
||||||
elif not job["hash"]:
|
elif not job["hash"]:
|
||||||
try:
|
try:
|
||||||
bos.utime(dst, times)
|
bos.utime(dst, times)
|
||||||
|
@ -2068,9 +2082,8 @@ class Up2k(object):
|
||||||
|
|
||||||
def _lastmodder(self):
|
def _lastmodder(self):
|
||||||
while True:
|
while True:
|
||||||
ready = []
|
ready = self.lastmod_q
|
||||||
while not self.lastmod_q.empty():
|
self.lastmod_q = []
|
||||||
ready.append(self.lastmod_q.get())
|
|
||||||
|
|
||||||
# self.log("lmod: got {}".format(len(ready)))
|
# self.log("lmod: got {}".format(len(ready)))
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
Loading…
Reference in a new issue