mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
detect more recursive symlinks
This commit is contained in:
parent
2f85c1fb18
commit
21c3570786
|
@ -210,11 +210,13 @@ class VFS(object):
|
||||||
rem, uname, scandir, incl_wo=False, lstat=lstat
|
rem, uname, scandir, incl_wo=False, lstat=lstat
|
||||||
)
|
)
|
||||||
|
|
||||||
if seen and not fsroot.startswith(seen[-1]) and fsroot in seen:
|
if (
|
||||||
self.log(
|
seen
|
||||||
"vfs.walk",
|
and (not fsroot.startswith(seen[-1]) or fsroot == seen[-1])
|
||||||
"bailing from symlink loop,\n {}\n {}".format(seen[-1], fsroot),
|
and fsroot in seen
|
||||||
)
|
):
|
||||||
|
m = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}/{}"
|
||||||
|
self.log("vfs.walk", m.format(seen[-1], fsroot, self.vpath, rem), 3)
|
||||||
return
|
return
|
||||||
|
|
||||||
seen = seen[:] + [fsroot]
|
seen = seen[:] + [fsroot]
|
||||||
|
|
|
@ -409,7 +409,7 @@ class Up2k(object):
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
excl = [x.replace("/", "\\") for x in excl]
|
excl = [x.replace("/", "\\") for x in excl]
|
||||||
|
|
||||||
n_add = self._build_dir(dbw, top, set(excl), top, nohash)
|
n_add = self._build_dir(dbw, top, set(excl), top, nohash, [])
|
||||||
n_rm = self._drop_lost(dbw[0], top)
|
n_rm = self._drop_lost(dbw[0], top)
|
||||||
if dbw[1]:
|
if dbw[1]:
|
||||||
self.log("commit {} new files".format(dbw[1]))
|
self.log("commit {} new files".format(dbw[1]))
|
||||||
|
@ -417,7 +417,21 @@ class Up2k(object):
|
||||||
|
|
||||||
return True, n_add or n_rm or do_vac
|
return True, n_add or n_rm or do_vac
|
||||||
|
|
||||||
def _build_dir(self, dbw, top, excl, cdir, nohash):
|
def _build_dir(self, dbw, top, excl, cdir, nohash, seen):
|
||||||
|
rcdir = cdir
|
||||||
|
if not ANYWIN:
|
||||||
|
try:
|
||||||
|
# a bit expensive but worth
|
||||||
|
rcdir = os.path.realpath(cdir)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if rcdir in seen:
|
||||||
|
m = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}"
|
||||||
|
self.log(m.format(seen[-1], rcdir, cdir), 3)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
seen = seen + [cdir]
|
||||||
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
|
||||||
|
@ -430,7 +444,7 @@ class Up2k(object):
|
||||||
if abspath in excl or abspath == histpath:
|
if abspath in excl or abspath == histpath:
|
||||||
continue
|
continue
|
||||||
# self.log(" dir: {}".format(abspath))
|
# self.log(" dir: {}".format(abspath))
|
||||||
ret += self._build_dir(dbw, top, excl, abspath, nohash)
|
ret += self._build_dir(dbw, top, excl, abspath, nohash, seen)
|
||||||
else:
|
else:
|
||||||
# self.log("file: {}".format(abspath))
|
# self.log("file: {}".format(abspath))
|
||||||
rp = abspath[len(top) + 1 :]
|
rp = abspath[len(top) + 1 :]
|
||||||
|
|
Loading…
Reference in a new issue