mirror of https://github.com/python/cpython.git
Fixed a bug: files that no longer exist remotely would never be
removed from .mirrorinfo. Now they are (even if -r is not specified -- the files are not removed, just their .mirrorinfo entry). Added a feature: the -s pattern option is also used to skip local files when removing (i.e. -r won't remove local files matching the -s patterns).
This commit is contained in:
parent
c59120ba17
commit
e41d00bb6a
|
@ -117,6 +117,7 @@ def mirrorsubdir(f, localdir):
|
||||||
listing = []
|
listing = []
|
||||||
if verbose: print 'Listing remote directory %s...' % pwd
|
if verbose: print 'Listing remote directory %s...' % pwd
|
||||||
f.retrlines('LIST', listing.append)
|
f.retrlines('LIST', listing.append)
|
||||||
|
filesfound = []
|
||||||
for line in listing:
|
for line in listing:
|
||||||
if verbose > 1: print '-->', `line`
|
if verbose > 1: print '-->', `line`
|
||||||
if mac:
|
if mac:
|
||||||
|
@ -157,6 +158,7 @@ def mirrorsubdir(f, localdir):
|
||||||
print 'Remembering subdirectory', filename
|
print 'Remembering subdirectory', filename
|
||||||
subdirs.append(filename)
|
subdirs.append(filename)
|
||||||
continue
|
continue
|
||||||
|
filesfound.append(filename)
|
||||||
if info.has_key(filename) and info[filename] == infostuff:
|
if info.has_key(filename) and info[filename] == infostuff:
|
||||||
if verbose > 1:
|
if verbose > 1:
|
||||||
print 'Already have this version of', filename
|
print 'Already have this version of', filename
|
||||||
|
@ -216,6 +218,18 @@ def mirrorsubdir(f, localdir):
|
||||||
int(round(kbytes/dt),)
|
int(round(kbytes/dt),)
|
||||||
print
|
print
|
||||||
#
|
#
|
||||||
|
# Remove files from info that are no longer remote
|
||||||
|
deletions = 0
|
||||||
|
for filename in info.keys():
|
||||||
|
if filename not in filesfound:
|
||||||
|
if verbose:
|
||||||
|
print "Removing obsolete info entry for",
|
||||||
|
print filename, "in", localdir or "."
|
||||||
|
del info[filename]
|
||||||
|
deletions = deletions + 1
|
||||||
|
if deletions:
|
||||||
|
writedict(info, infofilename)
|
||||||
|
#
|
||||||
# Remove local files that are no longer in the remote directory
|
# Remove local files that are no longer in the remote directory
|
||||||
try:
|
try:
|
||||||
if not localdir: names = os.listdir(os.curdir)
|
if not localdir: names = os.listdir(os.curdir)
|
||||||
|
@ -225,6 +239,16 @@ def mirrorsubdir(f, localdir):
|
||||||
for name in names:
|
for name in names:
|
||||||
if name[0] == '.' or info.has_key(name) or name in subdirs:
|
if name[0] == '.' or info.has_key(name) or name in subdirs:
|
||||||
continue
|
continue
|
||||||
|
skip = 0
|
||||||
|
for pat in skippats:
|
||||||
|
if fnmatch(name, pat):
|
||||||
|
if verbose > 1:
|
||||||
|
print 'Skip pattern', pat,
|
||||||
|
print 'matches', name
|
||||||
|
skip = 1
|
||||||
|
break
|
||||||
|
if skip:
|
||||||
|
continue
|
||||||
fullname = os.path.join(localdir, name)
|
fullname = os.path.join(localdir, name)
|
||||||
if not rmok:
|
if not rmok:
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|
Loading…
Reference in New Issue