From 838e5ce795980e172fa8567c205498e56ed89815 Mon Sep 17 00:00:00 2001 Message-Id: <838e5ce795980e172fa8567c205498e56ed89815.1714141166.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 26 May 2016 09:26:09 +0100 Subject: [PATCH] keys/tripe-keys.in: Remove unrecognized files from `base-dir'. Organization: Straylight/Edgeware From: Mark Wooding 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 | 5 ++++- keys/tripe-keys.conf.5.in | 4 +++- keys/tripe-keys.in | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/keys/tripe-keys.8.in b/keys/tripe-keys.8.in index 8017ae91..160e5bed 100644 --- a/keys/tripe-keys.8.in +++ b/keys/tripe-keys.8.in @@ -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 diff --git a/keys/tripe-keys.conf.5.in b/keys/tripe-keys.conf.5.in index 49e360d2..019fe3ba 100644 --- a/keys/tripe-keys.conf.5.in +++ b/keys/tripe-keys.conf.5.in @@ -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 diff --git a/keys/tripe-keys.in b/keys/tripe-keys.in index db577b62..46e1816a 100644 --- a/keys/tripe-keys.in +++ b/keys/tripe-keys.in @@ -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') -- [mdw]