about summary refs log tree commit diff
path: root/src/libstore/store-api.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-01T18·00+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-01T18·00+0000
commitb0d8e05be16e9887dbf3edcd6167c7f0b36dee5d (patch)
tree528ed2045ab784848cc70d87c851387d087b6163 /src/libstore/store-api.hh
parent0565b5f2b35dc153dc98e1e3bd37476aa13ee4f1 (diff)
* More operations.
* addToStore() and friends: don't do a round-trip to the worker if
  we're only interested in the path (i.e., in read-only mode).

Diffstat (limited to 'src/libstore/store-api.hh')
-rw-r--r--src/libstore/store-api.hh30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 31e8152e86bd..cbf2f7ef295f 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -54,12 +54,12 @@ public:
 
     /* Queries the set of outgoing FS references for a store path.
        The result is not cleared. */
-    virtual void queryReferences(const Path & storePath,
+    virtual void queryReferences(const Path & path,
         PathSet & references) = 0;
 
     /* Queries the set of incoming FS references for a store path.
        The result is not cleared. */
-    virtual void queryReferrers(const Path & storePath,
+    virtual void queryReferrers(const Path & path,
         PathSet & referrers) = 0;
 
     /* Copy the contents of a path to the store and register the
@@ -88,7 +88,7 @@ public:
     /* Ensure that a path is valid.  If it is not currently valid, it
        may be made valid by running a substitute (if defined for the
        path). */
-    virtual void ensurePath(const Path & storePath) = 0;
+    virtual void ensurePath(const Path & path) = 0;
 };
 
 
@@ -115,6 +115,30 @@ Path makeFixedOutputPath(bool recursive,
     string hashAlgo, Hash hash, string name);
 
 
+/* This is the preparatory part of addToStore() and addToStoreFixed();
+   it computes the store path to which srcPath is to be copied.
+   Returns the store path and the cryptographic hash of the
+   contents of srcPath. */
+std::pair<Path, Hash> computeStorePathForPath(bool fixed, bool recursive,
+    string hashAlgo, const Path & srcPath);
+
+/* Preparatory part of addTextToStore().
+
+   !!! Computation of the path should take the references given to
+   addTextToStore() into account, otherwise we have a (relatively
+   minor) security hole: a caller can register a source file with
+   bogus references.  If there are too many references, the path may
+   not be garbage collected when it has to be (not really a problem,
+   the caller could create a root anyway), or it may be garbage
+   collected when it shouldn't be (more serious).
+
+   Hashing the references would solve this (bogus references would
+   simply yield a different store path, so other users wouldn't be
+   affected), but it has some backwards compatibility issues (the
+   hashing scheme changes), so I'm not doing that for now. */
+Path computeStorePathForText(const string & suffix, const string & s);
+
+
 /* For now, there is a single global store API object, but we'll
    purify that in the future. */
 extern boost::shared_ptr<StoreAPI> store;