Some server side improvements for quick-mirror

This commit is contained in:
Kevin Fenzi 2016-06-22 21:51:06 +00:00
parent f4b3c5e624
commit d5e67b45fe
4 changed files with 13 additions and 9 deletions

View file

@ -36,7 +36,7 @@ def sha1(fname):
return sha1.hexdigest() return sha1.hexdigest()
def recursedir(path='.', skip=[]): def recursedir(path='.', skip=[], alwaysskip=['.~tmp~']):
"""Just like scandir, but recursively. """Just like scandir, but recursively.
Will skip everything in the skip array, but only at the top level Will skip everything in the skip array, but only at the top level
@ -45,8 +45,11 @@ def recursedir(path='.', skip=[]):
for entry in scandir(path): for entry in scandir(path):
if entry.name in skip: if entry.name in skip:
continue continue
if entry.name in alwaysskip:
continue
if entry.is_dir(follow_symlinks=False): if entry.is_dir(follow_symlinks=False):
for rentry in recursedir(entry.path): # Don't pass skip here, because we only skip in the top level
for rentry in recursedir(entry.path, alwaysskip=alwaysskip):
yield rentry yield rentry
yield entry yield entry
@ -60,16 +63,16 @@ def parseopts():
p.add_argument('-C', '--checksum-file', action='append', dest='checksum_files', p.add_argument('-C', '--checksum-file', action='append', dest='checksum_files',
help='Include checksums of all instances of the specified file.') help='Include checksums of all instances of the specified file.')
p.add_argument('-s', '--skip', action='store_true', p.add_argument('-s', '--skip', action='store_true',
help='Skip fullfiletimelist in the top directory') help='Skip the --filelist file in the top directory')
p.add_argument('-S', '--skip-file', action='append', dest='skip_files', p.add_argument('-S', '--skip-file', action='append', dest='skip_files',
help='Skip the specified file in the top directory.') help='Skip the specified file in the top directory.')
p.add_argument('-d', '--dir', help='Directory to scan (default: .).') p.add_argument('-d', '--dir', help='Directory to scan (default: .).')
p.add_argument('-t', '--timelist', type=argparse.FileType('w'), default=sys.stdout, p.add_argument('-t', '--timelist', type=argparse.FileType('w'), default=sys.stdout,
help='Filename of the file list with times (default: fullfiletimelist).') help='Filename of the file list with times (default: stdout).')
p.add_argument('-f', '--filelist', type=argparse.FileType('w'), default=null, p.add_argument('-f', '--filelist', type=argparse.FileType('w'), default=null,
help='Filename of the file list without times (default: fullfilelist).') help='Filename of the file list without times (default: no plain file list is generated).')
opts = p.parse_args() opts = p.parse_args()
@ -82,7 +85,8 @@ def parseopts():
opts.skip_files = opts.skip_files or [] opts.skip_files = opts.skip_files or []
if opts.skip: if opts.skip:
opts.skip_files += ['fullfiletimelist'] if not opts.timelist.name == '<stdout>':
opts.skip_files += [opts.timelist.name]
return opts return opts

View file

@ -14,7 +14,7 @@ fi
CREATE=/usr/local/bin/create-filelist CREATE=/usr/local/bin/create-filelist
# A single lockfile for everything we're modifying # A single lockfile for everything we're modifying
LOCKFILE=.lock.create-filelist LOCKFILE=/srv/.lock.create-filelist
# The directory where all of the modules live # The directory where all of the modules live
TOPD=/srv/pub TOPD=/srv/pub

View file

@ -14,7 +14,7 @@ fi
CREATE=/usr/local/bin/create-filelist CREATE=/usr/local/bin/create-filelist
# A single lockfile for everything we're modifying # A single lockfile for everything we're modifying
LOCKFILE=.lock.create-filelist LOCKFILE=/srv/.lock.create-filelist
# The directory where all of the modules live # The directory where all of the modules live
TOPD=/pub TOPD=/pub

View file

@ -14,7 +14,7 @@ fi
CREATE=/usr/local/bin/create-filelist CREATE=/usr/local/bin/create-filelist
# A single lockfile for everything we're modifying # A single lockfile for everything we're modifying
LOCKFILE=.lock.create-filelist LOCKFILE=/srv/.lock.create-filelist
# The directory where all of the modules live # The directory where all of the modules live
TOPD=/pub TOPD=/pub