chiark / gitweb /
keys/tripe-keys.in: Remove unrecognized files from `base-dir'.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 12 Jun 2016 12:31:36 +0000 (13:31 +0100)
In a sensible system, these turn out to be mostly signature files made
by old versions of the master key which don't exist any more.

You might want to think about making `upload-hook' delete the
corresponding files at the file server.

keys/tripe-keys.8.in
keys/tripe-keys.conf.5.in
keys/tripe-keys.in

index 8017ae919db5c9f9e85b9239d365b4839679c0c5..160e5bedbfd6290dea1dc36d297ef77efce9081f 100644 (file)
@@ -168,7 +168,10 @@ file.  Copy the results to the places named by
 .IR sig-file ,
 and
 .I conf-file
-respectively.  Run the
+respectively.  Remove unexpected files from the
+.IR base-dir ,
+since these tend to be signatures made by old master keys which don't
+work any more.  Run the
 .I upload-hook
 to copy things into the right places.
 .TP
index 49e360d26119c947812cc555cd8f94f8eaf0fdfc..019fe3ba008d1e5140da442993a681c89ab649db 100644 (file)
@@ -262,7 +262,9 @@ Hash function to use for key fingerprinting.  Default is
 Local base directory for the repository files.  This probably ought to
 end in a
 .RB ` / '
-character.  No default.
+character.  Unexpected files in this directory will be removed by the
+.B tripe-keys upload
+command.  No default.
 .TP
 .I repos-file
 Filename for local repository tarball.  Default is the concatenation of
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')