[Zope3-checkins] CVS: Zope3/src/zope/fssync - fsmerger.py:1.3

Guido van Rossum guido@python.org
Wed, 28 May 2003 14:32:45 -0400


Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv4593

Modified Files:
	fsmerger.py 
Log Message:
A few fixes found through careful unit testing:

- merge_dirs() should merge in the entry names as well as the names
  found in the directory listing.

- When creating a local directory, update the local entry for it.


=== Zope3/src/zope/fssync/fsmerger.py 1.2 => 1.3 ===
--- Zope3/src/zope/fssync/fsmerger.py:1.2	Thu May 15 11:32:23 2003
+++ Zope3/src/zope/fssync/fsmerger.py	Wed May 28 14:32:45 2003
@@ -74,12 +74,12 @@
 
     def merge_dirs(self, localdir, remotedir):
         """Merge remote directory into local directory."""
-        lnames = self.metadata.getnames(localdir)
-        rnames = self.metadata.getnames(remotedir)
+        lentrynames = self.metadata.getnames(localdir)
+        rentrynames = self.metadata.getnames(remotedir)
         lentry = self.metadata.getentry(localdir)
         rentry = self.metadata.getentry(remotedir)
 
-        if not lnames and not rnames:
+        if not lentrynames and not rentrynames:
 
             if not lentry:
                 if not rentry:
@@ -88,6 +88,7 @@
                 else:
                     if not exists(localdir):
                         fsutil.ensuredir(localdir)
+                        lentry.update(rentry)
                         self.reportdir("N", localdir)
                     else:
                         self.reportdir("*", localdir)
@@ -123,17 +124,23 @@
             lnames = dict([(normcase(name), name)
                            for name in os.listdir(localdir)])
         else:
-            if lentry.get("flag") != "removed" and (rentry or rnames):
+            if lentry.get("flag") != "removed" and (rentry or rentrynames):
                 fsutil.ensuredir(localdir)
                 lentry.update(rentry)
                 self.reportdir("N", localdir)
             lnames = {}
 
+        for name in lentrynames:
+            lnames[normcase(name)] = name
+
         if exists(remotedir):
             rnames = dict([(normcase(name), name)
                            for name in os.listdir(remotedir)])
         else:
             rnames = {}
+
+        for name in rentrynames:
+            rnames[normcase(name)] = name
 
         names = {}
         names.update(lnames)