mirror of
https://github.com/9001/copyparty.git
synced 2025-11-24 07:23:22 -07:00
Merge bec94291bd into fb9f0441c9
This commit is contained in:
commit
e6c676818a
32
bin/u2c.py
32
bin/u2c.py
|
|
@ -640,10 +640,26 @@ def walkdir(err, top, excl, seen):
|
||||||
yield ap, inf
|
yield ap, inf
|
||||||
else:
|
else:
|
||||||
err.append((ap, "irregular filetype 0%o" % (inf.st_mode,)))
|
err.append((ap, "irregular filetype 0%o" % (inf.st_mode,)))
|
||||||
|
|
||||||
|
def walkdir_no_recurse(err, top, excl, seen):
|
||||||
|
"""non-recursive statdir"""
|
||||||
|
atop = os.path.abspath(os.path.realpath(top))
|
||||||
|
if atop in seen:
|
||||||
|
err.append((top, "recursive-symlink"))
|
||||||
|
return
|
||||||
|
|
||||||
|
seen = seen[:] + [atop]
|
||||||
|
for ap, inf in sorted(statdir(err, top)):
|
||||||
|
if excl.match(ap):
|
||||||
|
continue
|
||||||
|
if stat.S_ISREG(inf.st_mode):
|
||||||
|
yield ap, inf
|
||||||
|
elif not stat.S_ISDIR(inf.st_mode):
|
||||||
|
err.append((ap, "irregular filetype 0%o" % (inf.st_mode,)))
|
||||||
|
|
||||||
|
|
||||||
def walkdirs(err, tops, excl):
|
def walkdirs(err, tops, excl, nr):
|
||||||
"""recursive statdir for a list of tops, yields [top, relpath, stat]"""
|
"""statdir for a list of tops, yields [top, relpath, stat]. nr determines if its (n)ot (r)ecursive"""
|
||||||
sep = "{0}".format(os.sep).encode("ascii")
|
sep = "{0}".format(os.sep).encode("ascii")
|
||||||
if not VT100:
|
if not VT100:
|
||||||
excl = excl.replace("/", r"\\")
|
excl = excl.replace("/", r"\\")
|
||||||
|
|
@ -675,8 +691,13 @@ def walkdirs(err, tops, excl):
|
||||||
if isdir:
|
if isdir:
|
||||||
yield stop, dn, os.stat(stop)
|
yield stop, dn, os.stat(stop)
|
||||||
|
|
||||||
|
if nr:
|
||||||
|
dir_traverse = walkdir_no_recurse
|
||||||
|
else:
|
||||||
|
dir_traverse = walkdir
|
||||||
|
|
||||||
if isdir:
|
if isdir:
|
||||||
for ap, inf in walkdir(err, top, ptn, []):
|
for ap, inf in dir_traverse(err, top, ptn, []):
|
||||||
yield stop, ap[len(stop) :].lstrip(sep), inf
|
yield stop, ap[len(stop) :].lstrip(sep), inf
|
||||||
else:
|
else:
|
||||||
d, n = top.rsplit(sep, 1)
|
d, n = top.rsplit(sep, 1)
|
||||||
|
|
@ -941,7 +962,7 @@ class Ctl(object):
|
||||||
nfiles = 0
|
nfiles = 0
|
||||||
nbytes = 0
|
nbytes = 0
|
||||||
err = []
|
err = []
|
||||||
for _, _, inf in walkdirs(err, ar.files, ar.x):
|
for _, _, inf in walkdirs(err, ar.files, ar.x, ar.nr):
|
||||||
if stat.S_ISDIR(inf.st_mode):
|
if stat.S_ISDIR(inf.st_mode):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -978,7 +999,7 @@ class Ctl(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.nfiles, self.nbytes = self.stats
|
self.nfiles, self.nbytes = self.stats
|
||||||
self.filegen = walkdirs([], ar.files, ar.x)
|
self.filegen = walkdirs([], ar.files, ar.x, ar.nr)
|
||||||
self.recheck = [] # type: list[File]
|
self.recheck = [] # type: list[File]
|
||||||
self.last_file = None
|
self.last_file = None
|
||||||
|
|
||||||
|
|
@ -1552,6 +1573,7 @@ NOTE: if server has --usernames enabled, then password is "username:password"
|
||||||
ap.add_argument("--ow", action="store_true", help="overwrite existing files instead of autorenaming")
|
ap.add_argument("--ow", action="store_true", help="overwrite existing files instead of autorenaming")
|
||||||
ap.add_argument("--owo", action="store_true", help="overwrite existing files if server-file is older")
|
ap.add_argument("--owo", action="store_true", help="overwrite existing files if server-file is older")
|
||||||
ap.add_argument("--spd", action="store_true", help="print speeds for each file")
|
ap.add_argument("--spd", action="store_true", help="print speeds for each file")
|
||||||
|
ap.add_argument("--nr", action="store_true", help="don't scan folders within a folder")
|
||||||
ap.add_argument("--version", action="store_true", help="show version and exit")
|
ap.add_argument("--version", action="store_true", help="show version and exit")
|
||||||
|
|
||||||
ap = app.add_argument_group("print links")
|
ap = app.add_argument_group("print links")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue