* Refactoring on the file names.

This commit is contained in:
Eelco Dolstra 2003-07-07 07:43:58 +00:00
parent 7952a8053c
commit 224c585aba
7 changed files with 17 additions and 60 deletions

View file

@ -20,7 +20,7 @@ test_LDADD = libnix.a -ldb_cxx-4 -lATerm
noinst_LIBRARIES = libnix.a noinst_LIBRARIES = libnix.a
libnix_a_SOURCES = util.cc hash.cc archive.cc md5.c \ 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-data-local:
$(INSTALL) -d $(localstatedir)/nix $(INSTALL) -d $(localstatedir)/nix

View file

@ -2,8 +2,8 @@
#include <iostream> #include <iostream>
#include "globals.hh" #include "globals.hh"
#include "eval.hh" #include "fstate.hh"
#include "values.hh" #include "store.hh"
#include "shared.hh" #include "shared.hh"

View file

@ -7,9 +7,9 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "eval.hh" #include "fstate.hh"
#include "globals.hh" #include "globals.hh"
#include "values.hh" #include "store.hh"
#include "db.hh" #include "db.hh"

View file

@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include "globals.hh" #include "globals.hh"
#include "values.hh" #include "store.hh"
#include "eval.hh" #include "fstate.hh"
#include "archive.hh" #include "archive.hh"
#include "shared.hh" #include "shared.hh"

View file

@ -3,7 +3,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "values.hh" #include "store.hh"
#include "globals.hh" #include "globals.hh"
#include "db.hh" #include "db.hh"
#include "archive.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) void deleteFromStore(const string & path)
{ {
string prefix = nixStore + "/"; string prefix = nixStore + "/";
@ -139,37 +117,16 @@ void deleteFromStore(const string & path)
string queryFromStore(Hash hash) string queryFromStore(Hash hash)
{ {
bool checkedNet = false; string fn, url;
while (1) { if (queryDB(nixDB, dbRefs, hash, fn)) {
string fn, url; /* Verify that the file hasn't changed. !!! race !!! slow */
if (hashPath(fn) != hash)
throw Error("file " + fn + " is stale");
if (queryDB(nixDB, dbRefs, hash, fn)) { return 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;
fn = fetchURL(url);
setDB(nixDB, dbRefs, hash, fn);
#endif
} }
throw Error(format("don't know a path with hash `%1%'") % (string) hash);
} }