about summary refs log tree commit diff
path: root/scripts/optimise-store.pl
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-19T16·14+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-19T16·14+0000
commitee6cf99660bbef843145731fbcdce9880c3bdb21 (patch)
tree89d9877f76cc268d2f63f990225afb45fbe6441d /scripts/optimise-store.pl
parent6dbed1bf38cd881ebf13aae39a4d988e4bd57f79 (diff)
* Doh! Of course we have to take execute permission into account.
* Restore the mtime on modified directories.

Diffstat (limited to 'scripts/optimise-store.pl')
-rwxr-xr-xscripts/optimise-store.pl11
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/optimise-store.pl b/scripts/optimise-store.pl
index 1ed89272d971..556174c2253f 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 (<LIST>) {
 
     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 (<LIST>) {
         $prevFile = $curFile;
         $prevHash = $curHash;
         $prevInode = $st[1];
+        $prevExec = ($st[2] & 0111) == 0111;
     }
 }