]> pd.if.org Git - zpackage/commitdiff
add passes to zpm-gc
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 3 Nov 2018 14:48:57 +0000 (14:48 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 3 Nov 2018 14:49:45 +0000 (14:49 +0000)
remove orphaned files

run sqlite vacuum and report before and after size

zpm-gc

diff --git a/zpm-gc b/zpm-gc
index f07cdaffd969d6c6bf4188cd672a123bf7e55be2..3c1716c4fcfb264682c0bac2888a3ad53716e77d 100755 (executable)
--- a/zpm-gc
+++ b/zpm-gc
@@ -38,6 +38,8 @@ done
 # remove orphaned rows in files table
 # references in packagefiles, notes, scripts, possibly others
 
+zpm shell $ZPMDB 'delete from files where hash in (select hash from filerefs where refcount = 0);'
+
 # remove old logs, given by date
 
 # remove acked notes
@@ -49,4 +51,10 @@ done
 # remove command history by date
 
 # compactify the database file
+osize=$(zpm stat -f '%s' $ZPMDB)
+zpm log -v -i -a 'gc compacting' -t $ZPMDB
+zpm shell $ZPMDB vacuum
+nsize=$(zpm stat -f '%s' $ZPMDB)
 
+printf 'original size %s\n' $osize
+printf 'new size %s\n' $nsize