mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
only drop tags when its safe
This commit is contained in:
parent
08f4695283
commit
a918cc67eb
|
@ -1405,7 +1405,7 @@ class Up2k(object):
|
||||||
try:
|
try:
|
||||||
ptop = dbv.realpath
|
ptop = dbv.realpath
|
||||||
cur, wark, _, _, _, _ = self._find_from_vpath(ptop, volpath)
|
cur, wark, _, _, _, _ = self._find_from_vpath(ptop, volpath)
|
||||||
self._forget_file(ptop, volpath, cur, wark)
|
self._forget_file(ptop, volpath, cur, wark, True)
|
||||||
finally:
|
finally:
|
||||||
cur.connection.commit()
|
cur.connection.commit()
|
||||||
|
|
||||||
|
@ -1491,10 +1491,10 @@ class Up2k(object):
|
||||||
fsize = st.st_size
|
fsize = st.st_size
|
||||||
|
|
||||||
if w:
|
if w:
|
||||||
if c2:
|
if c2 and c2 != c1:
|
||||||
self._copy_tags(c1, c2, w)
|
self._copy_tags(c1, c2, w)
|
||||||
|
|
||||||
self._forget_file(svn.realpath, srem, c1, w)
|
self._forget_file(svn.realpath, srem, c1, w, c1 != c2)
|
||||||
self._relink(w, svn.realpath, srem, dabs)
|
self._relink(w, svn.realpath, srem, dabs)
|
||||||
c1.connection.commit()
|
c1.connection.commit()
|
||||||
|
|
||||||
|
@ -1535,17 +1535,19 @@ class Up2k(object):
|
||||||
return cur, wark, ftime, fsize, ip, at
|
return cur, wark, ftime, fsize, ip, at
|
||||||
return cur, None, None, None, None, None
|
return cur, None, None, None, None, None
|
||||||
|
|
||||||
def _forget_file(self, ptop, vrem, cur, wark):
|
def _forget_file(self, ptop, vrem, cur, wark, drop_tags):
|
||||||
"""forgets file in db, fixes symlinks, does not delete"""
|
"""forgets file in db, fixes symlinks, does not delete"""
|
||||||
srd, sfn = vsplit(vrem)
|
srd, sfn = vsplit(vrem)
|
||||||
self.log("forgetting {}".format(vrem))
|
self.log("forgetting {}".format(vrem))
|
||||||
if wark:
|
if wark:
|
||||||
self.log("found {} in db".format(wark))
|
self.log("found {} in db".format(wark))
|
||||||
self._relink(wark, ptop, vrem, None)
|
if self._relink(wark, ptop, vrem, None):
|
||||||
|
drop_tags = False
|
||||||
|
|
||||||
q = "delete from mt where w=?"
|
if drop_tags:
|
||||||
cur.execute(q, (wark[:16],))
|
q = "delete from mt where w=?"
|
||||||
self.db_rm(cur, srd, sfn)
|
cur.execute(q, (wark[:16],))
|
||||||
|
self.db_rm(cur, srd, sfn)
|
||||||
|
|
||||||
reg = self.registry.get(ptop)
|
reg = self.registry.get(ptop)
|
||||||
if reg:
|
if reg:
|
||||||
|
@ -1581,7 +1583,7 @@ class Up2k(object):
|
||||||
self.log("found {} dupe: [{}] {}".format(wark, ptop, dvrem))
|
self.log("found {} dupe: [{}] {}".format(wark, ptop, dvrem))
|
||||||
|
|
||||||
if not dupes:
|
if not dupes:
|
||||||
return
|
return 0
|
||||||
|
|
||||||
full = {}
|
full = {}
|
||||||
links = {}
|
links = {}
|
||||||
|
@ -1618,6 +1620,8 @@ class Up2k(object):
|
||||||
|
|
||||||
self._symlink(dabs, alink, False)
|
self._symlink(dabs, alink, False)
|
||||||
|
|
||||||
|
return len(full) + len(links)
|
||||||
|
|
||||||
def _get_wark(self, cj):
|
def _get_wark(self, cj):
|
||||||
if len(cj["name"]) > 1024 or len(cj["hash"]) > 512 * 1024: # 16TiB
|
if len(cj["name"]) > 1024 or len(cj["hash"]) > 512 * 1024: # 16TiB
|
||||||
raise Pebkac(400, "name or numchunks not according to spec")
|
raise Pebkac(400, "name or numchunks not according to spec")
|
||||||
|
|
Loading…
Reference in a new issue