From 226c7c30456a59d110510a0140856c925dd48db2 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 13 Jan 2024 00:18:46 +0000 Subject: [PATCH] fix confusing behavior when reindexing files: when a file was reindexed (due to a change in size or last-modified timestamp) the uploader-IP would get removed, but the upload timestamp was ported over. This was intentional so there was probably a reason... new behavior is to keep both uploader-IP and upload timestamp if the file contents are unchanged (determined by comparing warks), and to discard both uploader-IP and upload timestamp if that is not the case --- copyparty/up2k.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 1ce4f8c3..c86cb63a 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -1228,7 +1228,7 @@ class Up2k(object): abspath = os.path.join(cdir, fn) nohash = reh.search(abspath) if reh else False - sql = "select w, mt, sz, at from up where rd = ? and fn = ?" + sql = "select w, mt, sz, ip, at from up where rd = ? and fn = ?" try: c = db.c.execute(sql, (rd, fn)) except: @@ -1237,7 +1237,7 @@ class Up2k(object): in_db = list(c.fetchall()) if in_db: self.pp.n -= 1 - dw, dts, dsz, at = in_db[0] + dw, dts, dsz, ip, at = in_db[0] if len(in_db) > 1: t = "WARN: multiple entries: [{}] => [{}] |{}|\n{}" rep_db = "\n".join([repr(x) for x in in_db]) @@ -1259,6 +1259,8 @@ class Up2k(object): db.n += 1 in_db = [] else: + dw = "" + ip = "" at = 0 self.pp.msg = "a%d %s" % (self.pp.n, abspath) @@ -1282,8 +1284,12 @@ class Up2k(object): wark = up2k_wark_from_hashlist(self.salt, sz, hashes) + if dw and dw != wark: + ip = "" + at = 0 + # skip upload hooks by not providing vflags - self.db_add(db.c, {}, rd, fn, lmod, sz, "", "", wark, "", "", "", at) + self.db_add(db.c, {}, rd, fn, lmod, sz, "", "", wark, "", "", ip, at) db.n += 1 ret += 1 td = time.time() - db.t