[Zope3-checkins] CVS: Zope3/src/zope/fssync - fssync.py:1.17
Guido van Rossum
guido@python.org
Wed, 14 May 2003 21:55:08 -0400
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv5419
Modified Files:
fssync.py
Log Message:
Fix major outstanding bug: updating a single file no longer deletes
all other file from the directory.
=== Zope3/src/zope/fssync/fssync.py 1.16 => 1.17 ===
--- Zope3/src/zope/fssync/fssync.py:1.16 Wed May 14 18:16:09 2003
+++ Zope3/src/zope/fssync/fssync.py Wed May 14 21:55:08 2003
@@ -266,9 +266,12 @@
if exists(target) and not isdir(target):
raise Error("target should be a directory", target)
fsutil.ensuredir(target)
+ i = rootpath.rfind("/")
+ tail = rootpath[i+1:]
+ assert tail
fp, headers = self.network.httpreq(rootpath, "@@toFS.zip")
try:
- self.merge_zipfile(fp, target)
+ self.merge_zipfile(fp, target, tail)
finally:
fp.close()
self.network.saverooturl(target)
@@ -314,7 +317,7 @@
if isfile(zipfile):
os.remove(zipfile)
try:
- self.merge_zipfile(outfp, head)
+ self.merge_zipfile(outfp, head, tail)
finally:
outfp.close()
@@ -327,11 +330,11 @@
path = entry["path"]
fp, headers = self.network.httpreq(path, "@@toFS.zip")
try:
- self.merge_zipfile(fp, head)
+ self.merge_zipfile(fp, head, tail)
finally:
fp.close()
- def merge_zipfile(self, fp, localdir):
+ def merge_zipfile(self, fp, localdir, tail):
zipfile = tempfile.mktemp(".zip")
try:
tfp = open(zipfile, "wb")
@@ -347,7 +350,7 @@
if sts:
raise Error("unzip failed:\n%s" % output)
m = FSMerger(self.metadata, self.reporter)
- m.merge(localdir, tmpdir)
+ m.merge(join(localdir, tail), join(tmpdir, tail))
self.metadata.flush()
print "All done."
finally: