]> arthur.barton.de Git - bup.git/blobdiff - cmd/server-cmd.py
options: remove unused 'exe' parameter
[bup.git] / cmd / server-cmd.py
index 42ec1d4ef4a59242928ce9a5d55f5b249b288369..3bc998bcfe7927e70332bc0c2f3a1c8774a1eb2d 100755 (executable)
@@ -51,12 +51,15 @@ def send_index(conn, name):
 def receive_objects_v2(conn, junk):
     global suspended_w
     git.check_repo_or_die()
-    suggested = {}
+    suggested = set()
     if suspended_w:
         w = suspended_w
         suspended_w = None
     else:
-        w = git.PackWriter()
+        if dumb_server_mode:
+            w = git.PackWriter(objcache_maker=None)
+        else:
+            w = git.PackWriter()
     while 1:
         ns = conn.read(4)
         if not ns:
@@ -84,43 +87,29 @@ def receive_objects_v2(conn, junk):
         n -= 20 + 4
         buf = conn.read(n)  # object sizes in bup are reasonably small
         #debug2('read %d bytes\n' % n)
-        if len(buf) < n:
-            w.abort()
-            raise Exception('object read: expected %d bytes, got %d\n'
-                            % (n, len(buf)))
-        if dumb_server_mode:
-            oldpack = None
-        else:
+        _check(w, n, len(buf), 'object read: expected %d bytes, got %d\n')
+        if not dumb_server_mode:
             oldpack = w.exists(shar)
-        # FIXME: we only suggest a single index per cycle, because the client
-        # is currently too dumb to download more than one per cycle anyway.
-        # Actually we should fix the client, but this is a minor optimization
-        # on the server side.
-        if not suggested and \
-          oldpack and (oldpack == True or oldpack.endswith('.midx')):
-            # FIXME: we shouldn't really have to know about midx files
-            # at this layer.  But exists() on a midx doesn't return the
-            # packname (since it doesn't know)... probably we should just
-            # fix that deficiency of midx files eventually, although it'll
-            # make the files bigger.  This method is certainly not very
-            # efficient.
-            oldpack = w.objcache.packname_containing(shar)
-            debug2('new suggestion: %r\n' % oldpack)
-            assert(oldpack)
-            assert(oldpack != True)
-            assert(not oldpack.endswith('.midx'))
-            w.objcache.refresh()
-        if not suggested and oldpack:
-            assert(oldpack.endswith('.idx'))
-            (dir,name) = os.path.split(oldpack)
-            if not (name in suggested):
-                debug1("bup server: suggesting index %s\n" % name)
-                conn.write('index %s\n' % name)
-                suggested[name] = 1
-        else:
-            nw, crc = w._raw_write([buf], sha=shar)
-            _check(w, crcr, crc, 'object read: expected crc %d, got %d\n')
-            _check(w, n, nw, 'object read: expected %d bytes, got %d\n')
+            if oldpack:
+                if oldpack == True or oldpack.endswith('.midx'):
+                    # FIXME: we shouldn't really have to know about midx files
+                    # at this layer.  But exists() on a midx doesn't return the
+                    # packname (since it doesn't know)... probably we should
+                    # just fix that deficiency of midx files eventually,
+                    # although it'll make the files bigger.  This method is
+                    # certainly not very efficient.
+                    oldpack = w.objcache.packname_containing(shar)
+                    debug2('new suggestion: %r\n' % oldpack)
+                    w.objcache.refresh()
+                assert(oldpack.endswith('.idx'))
+                (dir,name) = os.path.split(oldpack)
+                if not (name in suggested):
+                    debug1("bup server: suggesting index %s\n" % name)
+                    conn.write('index %s\n' % name)
+                    suggested.add(name)
+                continue
+        nw, crc = w._raw_write((buf,), sha=shar)
+        _check(w, crcr, crc, 'object read: expected crc %d, got %d\n')
     # NOTREACHED
     
 
@@ -167,7 +156,7 @@ def cat(conn, id):
 optspec = """
 bup server
 """
-o = options.Options('bup server', optspec)
+o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 
 if extra: