about summary refs log tree commit diff
path: root/src/nix-store
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-03-22T17·36+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-03-22T17·36+0000
commit77d272623fb4fd57cf27d4b92a7dc1713a2d4098 (patch)
tree37c40b30768dfe348527a93237652e041280419a /src/nix-store
parent7e05b8b75e0f4b370cc7d4b78b3fb18a3678b360 (diff)
* NAR archives: handle files larger than 2^32 bytes. Previously it
  would just silently store only (fileSize % 2^32) bytes.
* Use posix_fallocate if available when unpacking archives.
* Provide a better error message when trying to unpack something that
  isn't a NAR archive.

Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/nix-store.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index f6271d56aafd..4a70d870a563 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -617,16 +617,19 @@ static void opExport(Strings opFlags, Strings opArgs)
 static void opImport(Strings opFlags, Strings opArgs)
 {
     bool requireSignature = false;
-    for (Strings::iterator i = opFlags.begin();
-         i != opFlags.end(); ++i)
+    foreach (Strings::iterator, i, opFlags)
         if (*i == "--require-signature") requireSignature = true;
         else throw UsageError(format("unknown flag `%1%'") % *i);
     
     if (!opArgs.empty()) throw UsageError("no arguments expected");
     
     FdSource source(STDIN_FILENO);
-    while (readInt(source) == 1)
+    while (true) {
+        int n = readInt(source);
+        if (n == 0) break;
+        if (n != 1) throw Error("input doesn't look like something created by `nix-store --export'");
         cout << format("%1%\n") % store->importPath(requireSignature, source) << std::flush;
+    }
 }