From ee6cf99660bbef843145731fbcdce9880c3bdb21 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 19 Sep 2006 16:14:15 +0000 Subject: [PATCH] * Doh! Of course we have to take execute permission into account. * Restore the mtime on modified directories. --- scripts/optimise-store.pl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/optimise-store.pl b/scripts/optimise-store.pl index 1ed89272d..556174c22 100755 --- a/scripts/optimise-store.pl +++ b/scripts/optimise-store.pl @@ -4,7 +4,8 @@ use strict; use File::Basename; -my @paths = ("/nix/store"); +#my @paths = ("/nix/store"); +my @paths = ("test"); print "hashing...\n"; @@ -37,6 +38,7 @@ sub atomicLink { rename $tmpNew, $new or die "cannot rename `$tmpNew' to `$new': $!"; chmod ($st[2], $dir) or die "cannot restore permission on `$dir': $!"; + utime ($st[8], $st[9], $dir) or die "cannot restore timestamp on `$dir': $!"; } @@ -47,6 +49,7 @@ open LIST, "<$hashList.sorted" or die; my $prevFile; my $prevHash; my $prevInode; +my $prevExec; my $totalSpace = 0; my $savedSpace = 0; @@ -61,8 +64,11 @@ while () { my $fileSize = $st[7]; $totalSpace += $fileSize; + my $isExec = ($st[2] & 0111) == 0111; - if (defined $prevHash && $curHash eq $prevHash) { + if (defined $prevHash && $curHash eq $prevHash + && $prevExec == $isExec) + { if ($st[1] != $prevInode) { print "$curFile = $prevFile\n"; @@ -74,6 +80,7 @@ while () { $prevFile = $curFile; $prevHash = $curHash; $prevInode = $st[1]; + $prevExec = ($st[2] & 0111) == 0111; } }