about summary refs log tree commit diff
path: root/src/libstore/gc.cc
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2007-11-15T03·47+0000
committerMichael Raskin <7c6f434c@mail.ru>2007-11-15T03·47+0000
commit6fc60e2060be5958c2aad1c859ee60bae5e23980 (patch)
tree6bcec3f010df805204b679e47dc964476ffff36c /src/libstore/gc.cc
parent5b74a5957023bd51b7ba32fc244cb08931507a52 (diff)
Added possibility to specify garbage collection levels for store paths; so packages can share intermediate results of compilation and GC will collect it automatically while never touching tarballs, for example.
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r--src/libstore/gc.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index e2e6c23fd559..53ee100f96b7 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -4,6 +4,7 @@
 #include "local-store.hh"
 #include "db.hh"
 #include "util.hh"
+#include "gc.hh"
 
 #include <boost/shared_ptr.hpp>
 
@@ -445,6 +446,8 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
         queryBoolSetting("gc-keep-outputs", false);
     bool gcKeepDerivations =
         queryBoolSetting("gc-keep-derivations", true);
+    unsigned int gcKeepOutputsThreshold = 
+        queryIntSetting ("gc-keep-outputs-threshold", defaultGcLevel);
 
     /* Acquire the global GC root.  This prevents
        a) New roots from being added.
@@ -496,10 +499,18 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
              i != livePaths.end(); ++i)
             if (isDerivation(*i)) {
                 Derivation drv = derivationFromPath(*i);
-                for (DerivationOutputs::iterator j = drv.outputs.begin();
-                     j != drv.outputs.end(); ++j)
-                    if (store->isValidPath(j->second.path))
-                        computeFSClosure(j->second.path, livePaths);
+
+		string gcLevelStr = drv.env["__gcLevel"];
+		int gcLevel;
+		if (!string2Int(gcLevelStr,gcLevel)) {
+		    gcLevel = defaultGcLevel;
+		}
+		
+		if (gcLevel >= gcKeepOutputsThreshold)    
+		    for (DerivationOutputs::iterator j = drv.outputs.begin();
+		            j != drv.outputs.end(); ++j)
+			if (store->isValidPath(j->second.path))
+			    computeFSClosure(j->second.path, livePaths);
             }
     }