chiark / gitweb /
keys/tripe-keys.in: Remove unrecognized files from `base-dir'.
[tripe] / keys / tripe-keys.in
index db577b6266869da79a030b335f7478fb06cbf5ce..46e1816a886ad8e46f56caba465ba9498d6fdb0e 100644 (file)
@@ -420,6 +420,16 @@ def cmd_upload(args):
     for base in commit:
       new = '%s.new' % base
       OS.rename(new, base)
+
+    ## Remove files in the base-dir which don't correspond to ones we just
+    ## committed
+    allow = {}
+    basedir = conf['base-dir']
+    bdl = len(basedir)
+    for base in commit:
+      if base.startswith(basedir): allow[base[bdl:]] = 1
+    for found in OS.listdir(basedir):
+      if found not in allow: OS.remove(OS.path.join(basedir, found))
   finally:
     OS.chdir(cwd)
     rmtree('tmp')