From 5d8da9e8dfaa4d88f128934461d639687da26d57 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 13 Nov 2018 10:21:23 +0100 Subject: add helper to clean old metadata in repository --- cleanoldmeta | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 cleanoldmeta (limited to 'cleanoldmeta') diff --git a/cleanoldmeta b/cleanoldmeta new file mode 100755 index 0000000..21714a9 --- /dev/null +++ b/cleanoldmeta @@ -0,0 +1,43 @@ +#!/usr/bin/php +isFile()) { + continue; + } + if (preg_match("/^[^-]*-(.*)$/", $file->getFilename(), $reg)) { + $n = $reg[1]; + $tab[$n][$file->getMtime()] = $file->getFilename(); + } + } + foreach ($tab as $n => $files) { + if (count($tab[$n]) > KEEP) { + echo " $n\n"; + krsort($tab[$n]); + while (count($tab[$n]) > KEEP) { + $f = array_pop($tab[$n]); + if (unlink("$path/$f")) { + echo " $f\n"; + } + } + } + } +} + +if ($_SERVER['argc'] < 2) { + die("\nusage {$_SERVER['argv'][0]} path/to/repodata\n"); +} + +for ($i=1 ; $i<$_SERVER['argc'] ; $i++) { + clean($_SERVER['argv'][$i]); +} -- cgit