From 224c585aba5e450fa47e41c4cc19dac2d0c6fe2a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 7 Jul 2003 07:43:58 +0000 Subject: [PATCH] * Refactoring on the file names. --- src/Makefile.am | 2 +- src/fix.cc | 4 +-- src/{eval.cc => fstate.cc} | 4 +-- src/{eval.hh => fstate.hh} | 0 src/nix.cc | 4 +-- src/{values.cc => store.cc} | 63 ++++++------------------------------- src/{values.hh => store.hh} | 0 7 files changed, 17 insertions(+), 60 deletions(-) rename src/{eval.cc => fstate.cc} (99%) rename src/{eval.hh => fstate.hh} (100%) rename src/{values.cc => store.cc} (62%) rename src/{values.hh => store.hh} (100%) diff --git a/src/Makefile.am b/src/Makefile.am index 22b27d88a..5488e133a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,7 @@ test_LDADD = libnix.a -ldb_cxx-4 -lATerm noinst_LIBRARIES = libnix.a libnix_a_SOURCES = util.cc hash.cc archive.cc md5.c \ - eval.cc values.cc globals.cc db.cc + fstate.cc store.cc globals.cc db.cc install-data-local: $(INSTALL) -d $(localstatedir)/nix diff --git a/src/fix.cc b/src/fix.cc index 33bcdd9a1..fdf12ffef 100644 --- a/src/fix.cc +++ b/src/fix.cc @@ -2,8 +2,8 @@ #include #include "globals.hh" -#include "eval.hh" -#include "values.hh" +#include "fstate.hh" +#include "store.hh" #include "shared.hh" diff --git a/src/eval.cc b/src/fstate.cc similarity index 99% rename from src/eval.cc rename to src/fstate.cc index 354ecb6cc..8003a1b38 100644 --- a/src/eval.cc +++ b/src/fstate.cc @@ -7,9 +7,9 @@ #include #include -#include "eval.hh" +#include "fstate.hh" #include "globals.hh" -#include "values.hh" +#include "store.hh" #include "db.hh" diff --git a/src/eval.hh b/src/fstate.hh similarity index 100% rename from src/eval.hh rename to src/fstate.hh diff --git a/src/nix.cc b/src/nix.cc index f2d00394f..dc9d04148 100644 --- a/src/nix.cc +++ b/src/nix.cc @@ -1,8 +1,8 @@ #include #include "globals.hh" -#include "values.hh" -#include "eval.hh" +#include "store.hh" +#include "fstate.hh" #include "archive.hh" #include "shared.hh" diff --git a/src/values.cc b/src/store.cc similarity index 62% rename from src/values.cc rename to src/store.cc index 5db04036c..68a1cd1e2 100644 --- a/src/values.cc +++ b/src/store.cc @@ -3,7 +3,7 @@ #include #include -#include "values.hh" +#include "store.hh" #include "globals.hh" #include "db.hh" #include "archive.hh" @@ -105,28 +105,6 @@ void addToStore(string srcPath, string & dstPath, Hash & hash) } -#if 0 -/* Download object referenced by the given URL into the sources - directory. Return the file name it was downloaded to. */ -string fetchURL(string url) -{ - string filename = baseNameOf(url); - string fullname = nixSourcesDir + "/" + filename; - struct stat st; - if (stat(fullname.c_str(), &st)) { - cerr << "fetching " << url << endl; - /* !!! quoting */ - string shellCmd = - "cd " + nixSourcesDir + " && wget --quiet -N \"" + url + "\""; - int res = system(shellCmd.c_str()); - if (WEXITSTATUS(res) != 0) - throw Error("cannot fetch " + url); - } - return fullname; -} -#endif - - void deleteFromStore(const string & path) { string prefix = nixStore + "/"; @@ -139,37 +117,16 @@ void deleteFromStore(const string & path) string queryFromStore(Hash hash) { - bool checkedNet = false; + string fn, url; - while (1) { - - string fn, url; - - if (queryDB(nixDB, dbRefs, hash, fn)) { - - /* Verify that the file hasn't changed. !!! race !!! slow */ - if (hashPath(fn) != hash) - throw Error("file " + fn + " is stale"); - - return fn; - } - - throw Error("a file with hash " + (string) hash + " is required, " - "but it is not known to exist locally or on the network"); -#if 0 - if (checkedNet) - throw Error("consistency problem: file fetched from " + url + - " should have hash " + (string) hash + ", but it doesn't"); - - if (!queryDB(nixDB, dbNetSources, hash, url)) - throw Error("a file with hash " + (string) hash + " is required, " - "but it is not known to exist locally or on the network"); - - checkedNet = true; + if (queryDB(nixDB, dbRefs, hash, fn)) { - fn = fetchURL(url); - - setDB(nixDB, dbRefs, hash, fn); -#endif + /* Verify that the file hasn't changed. !!! race !!! slow */ + if (hashPath(fn) != hash) + throw Error("file " + fn + " is stale"); + + return fn; } + + throw Error(format("don't know a path with hash `%1%'") % (string) hash); } diff --git a/src/values.hh b/src/store.hh similarity index 100% rename from src/values.hh rename to src/store.hh