about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-01-22T21·07+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-01-22T21·07+0100
commit99ed558a93216288e50b11132f2a00a74cc6bb7f (patch)
treef01c32e5640fc699fd4365495484d6650a84ba49
parent1943b60ad820730a74d1dffcdddac396d0c1cb00 (diff)
Correctly handle missing logs
-rw-r--r--src/nix-store/nix-store.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 3e1946e8db61..8d26fc7845f3 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -460,7 +460,7 @@ static void opReadLog(Strings opFlags, Strings opArgs)
     foreach (Strings::iterator, i, opArgs) {
         Path path = useDeriver(followLinksToStorePath(*i));
 
-        for (int j = 0; j < 2; j++) {
+        for (int j = 0; j <= 2; j++) {
             if (j == 2) throw Error(format("build log of derivation `%1%' is not available") % path);
 
             string baseName = baseNameOf(path);
@@ -474,6 +474,7 @@ static void opReadLog(Strings opFlags, Strings opArgs)
                 /* !!! Make this run in O(1) memory. */
                 string log = readFile(logPath);
                 writeFull(STDOUT_FILENO, (const unsigned char *) log.data(), log.size());
+                break;
             }
 
             else if (pathExists(logBz2Path)) {
@@ -492,6 +493,7 @@ static void opReadLog(Strings opFlags, Strings opArgs)
                     writeFull(STDOUT_FILENO, buf, n);
                 } while (err != BZ_STREAM_END);
                 BZ2_bzReadClose(&err, bz);
+                break;
             }
         }
     }