[Zope3-checkins] CVS: Zope3/src/zope/fssync - snarf.py:1.2

Guido van Rossum guido@python.org
Tue, 27 May 2003 10:03:04 -0400


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

Modified Files:
	snarf.py 
Log Message:
Simplify -- we don't need to handle directories at all, so remove them
from the protocol.


=== Zope3/src/zope/fssync/snarf.py 1.1 => 1.2 ===
--- Zope3/src/zope/fssync/snarf.py:1.1	Tue May 20 15:09:15 2003
+++ Zope3/src/zope/fssync/snarf.py	Tue May 27 10:03:04 2003
@@ -16,13 +16,12 @@
 This is for transferring collections of files over HTTP where the key
 need is for simple software.
 
-The format is as follows:
+The format is dead simple: each file is represented by the string
 
-- for directory entries:
-  '/ <pathname>\n'
+    '<size> <pathname>\n'
 
-- for file entries:
-  '<size> <pathname>\n' followed by exactly <size> bytes
+followed by exactly <size> bytes.  Directories are not represented
+explicitly.
 
 Pathnames are always relative and always use '/' for delimiters, and
 should not use '.' or '..' or '' as components.  All files are read
@@ -112,16 +111,13 @@
             if not infoline.endswith("\n"):
                 raise IOError("incomplete info line %r" % infoline)
             infoline = infoline[:-1]
-            what, path = infoline.split(" ", 1)
-            if what == "/":
-                self.makedir(path)
-            else:
-                size = int(what)
-                f = self.createfile(path)
-                try:
-                    copybytes(size, self.istr, f)
-                finally:
-                    f.close()
+            sizestr, path = infoline.split(" ", 1)
+            size = int(sizestr)
+            f = self.createfile(path)
+            try:
+                copybytes(size, self.istr, f)
+            finally:
+                f.close()
 
     def makedir(self, path):
         fspath = self.translatepath(path)