mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
support symlinks as volume root
This commit is contained in:
parent
7755392f57
commit
4878eb2c45
|
@ -554,12 +554,16 @@ class Up2k(object):
|
||||||
for d in all_vols
|
for d in all_vols
|
||||||
if d != vol and (d.vpath.startswith(vol.vpath + "/") or not vol.vpath)
|
if d != vol and (d.vpath.startswith(vol.vpath + "/") or not vol.vpath)
|
||||||
]
|
]
|
||||||
|
excl += [absreal(x) for x in excl]
|
||||||
|
excl += list(self.asrv.vfs.histtab.values())
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
excl = [x.replace("/", "\\") for x in excl]
|
excl = [x.replace("/", "\\") for x in excl]
|
||||||
|
|
||||||
|
excl = set(excl)
|
||||||
|
rtop = absreal(top)
|
||||||
n_add = n_rm = 0
|
n_add = n_rm = 0
|
||||||
try:
|
try:
|
||||||
n_add = self._build_dir(dbw, top, set(excl), top, rei, reh, [])
|
n_add = self._build_dir(dbw, top, excl, top, rtop, rei, reh, [])
|
||||||
n_rm = self._drop_lost(dbw[0], top)
|
n_rm = self._drop_lost(dbw[0], top)
|
||||||
except:
|
except:
|
||||||
m = "failed to index volume [{}]:\n{}"
|
m = "failed to index volume [{}]:\n{}"
|
||||||
|
@ -572,8 +576,7 @@ 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, rei, reh, seen):
|
def _build_dir(self, dbw, top, excl, cdir, rcdir, rei, reh, seen):
|
||||||
rcdir = absreal(cdir) # a bit expensive but worth
|
|
||||||
if rcdir in seen:
|
if rcdir in seen:
|
||||||
m = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}"
|
m = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}"
|
||||||
self.log(m.format(seen[-1], rcdir, cdir), 3)
|
self.log(m.format(seen[-1], rcdir, cdir), 3)
|
||||||
|
@ -581,7 +584,6 @@ class Up2k(object):
|
||||||
|
|
||||||
seen = seen + [rcdir]
|
seen = seen + [rcdir]
|
||||||
self.pp.msg = "a{} {}".format(self.pp.n, cdir)
|
self.pp.msg = "a{} {}".format(self.pp.n, cdir)
|
||||||
histpath = self.asrv.vfs.histtab[top]
|
|
||||||
ret = 0
|
ret = 0
|
||||||
seen_files = {} # != inames; files-only for dropcheck
|
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)
|
||||||
|
@ -596,14 +598,15 @@ class Up2k(object):
|
||||||
lmod = int(inf.st_mtime)
|
lmod = int(inf.st_mtime)
|
||||||
sz = inf.st_size
|
sz = inf.st_size
|
||||||
if stat.S_ISDIR(inf.st_mode):
|
if stat.S_ISDIR(inf.st_mode):
|
||||||
if abspath in excl or abspath == histpath:
|
rap = absreal(abspath)
|
||||||
|
if abspath in excl or rap in excl:
|
||||||
continue
|
continue
|
||||||
if iname == ".th" and bos.path.isdir(os.path.join(abspath, "top")):
|
if iname == ".th" and bos.path.isdir(os.path.join(abspath, "top")):
|
||||||
# abandoned or foreign, skip
|
# abandoned or foreign, skip
|
||||||
continue
|
continue
|
||||||
# self.log(" dir: {}".format(abspath))
|
# self.log(" dir: {}".format(abspath))
|
||||||
try:
|
try:
|
||||||
ret += self._build_dir(dbw, top, excl, abspath, rei, reh, seen)
|
ret += self._build_dir(dbw, top, excl, abspath, rap, rei, reh, seen)
|
||||||
except:
|
except:
|
||||||
m = "failed to index subdir [{}]:\n{}"
|
m = "failed to index subdir [{}]:\n{}"
|
||||||
self.log(m.format(abspath, min_ex()), c=1)
|
self.log(m.format(abspath, min_ex()), c=1)
|
||||||
|
|
Loading…
Reference in a new issue