From 5ab09769e111e8ac1422edbc1df2b291daac130c Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 15 Mar 2025 23:54:32 +0000 Subject: [PATCH] move symlinks as-is; don't expand into full files previously, when moving or renaming a symlink to a file (or a folder with symlinks inside), the dedup setting would decide whether those links would be expanded into full files or not with dedup disabled (which is the default), all symlinks would be expanded during a move operation now, the dedup-setting is ignored when files/folders are moved, but it still applies when uploading or copying files/folders * absolute symlinks are moved as-is * relative symlinks are rewritten as necessary, assuming both source and destination is known in db --- copyparty/authsrv.py | 3 ++- copyparty/up2k.py | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 013c01c1..377a65dc 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -1606,7 +1606,8 @@ class AuthSrv(object): if enshare: import sqlite3 - shv = VFS(self.log_func, "", shr, shr, AXS(), {}) + zsd = {"d2d": True, "tcolor": self.args.tcolor} + shv = VFS(self.log_func, "", shr, shr, AXS(), zsd) db_path = self.args.shr_db db = sqlite3.connect(db_path) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index d267780b..b7bb9252 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -3426,6 +3426,7 @@ class Up2k(object): rm: bool = False, lmod: float = 0, fsrc: Optional[str] = None, + is_mv: bool = False, ) -> None: if src == dst or (fsrc and fsrc == dst): t = "symlinking a file to itself?? orig(%s) fsrc(%s) link(%s)" @@ -3442,7 +3443,7 @@ class Up2k(object): linked = False try: - if not flags.get("dedup"): + if not is_mv and not flags.get("dedup"): raise Exception("dedup is disabled in config") lsrc = src @@ -4601,7 +4602,7 @@ class Up2k(object): dlink = bos.readlink(sabs) dlink = os.path.join(os.path.dirname(sabs), dlink) dlink = bos.path.abspath(dlink) - self._symlink(dlink, dabs, dvn.flags, lmod=ftime) + self._symlink(dlink, dabs, dvn.flags, lmod=ftime, is_mv=True) wunlink(self.log, sabs, svn.flags) else: atomic_move(self.log, sabs, dabs, svn.flags) @@ -4820,7 +4821,7 @@ class Up2k(object): flags = self.flags.get(ptop) or {} atomic_move(self.log, sabs, slabs, flags) bos.utime(slabs, (int(time.time()), int(mt)), False) - self._symlink(slabs, sabs, flags, False) + self._symlink(slabs, sabs, flags, False, is_mv=True) full[slabs] = (ptop, rem) sabs = slabs @@ -4879,7 +4880,9 @@ class Up2k(object): # (for example a volume with symlinked dupes but no --dedup); # fsrc=sabs is then a source that currently resolves to copy - self._symlink(dabs, alink, flags, False, lmod=lmod or 0, fsrc=sabs) + self._symlink( + dabs, alink, flags, False, lmod=lmod or 0, fsrc=sabs, is_mv=True + ) return len(full) + len(links)