@@ -2098,7 +2098,13 @@ nothing and exit immediately.
@itemx -d
Attempt to delete all the store files and directories specified as
arguments. This fails if some of the files are not in the store, or if
-they are still live.
+they are still live (with behaviour can be changed with
+@option{--keep-going}).
+
+@item --keep-going
+@itemx -k
+Keep going when @option{--delete} is given and some of the store files
+and directories specified as arguments fail to re removed.
@item --list-failures
List store items corresponding to cached build failures.
@@ -72,6 +72,9 @@ Invoke the garbage collector.\n"))
--clear-failures remove PATHS from the set of cached failures"))
(newline)
(display (_ "
+ -k, --keep-going keep going when some of th pathes can not be deleted"))
+ (newline)
+ (display (_ "
-h, --help display this help and exit"))
(display (_ "
-V, --version display version information and exit"))
@@ -107,6 +110,9 @@ Invoke the garbage collector.\n"))
(lambda (opt name arg result)
(alist-cons 'action 'delete
(alist-delete 'action result))))
+ (option '(#\k "keep-going") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'keep-going? #t result)))
(option '("optimize") #f #f
(lambda (opt name arg result)
(alist-cons 'action 'optimize
@@ -228,7 +234,8 @@ Invoke the garbage collector.\n"))
(let-values (((paths freed) (collect-garbage store)))
(info (_ "freed ~h bytes~%") freed))))))
((delete)
- (delete-paths store (map direct-store-path paths)))
+ (delete-paths store (map direct-store-path paths)
+ #:keep-going? (assoc-ref opts 'keep-going?)))
((list-references)
(list-relatives references))
((list-requisites)
@@ -137,7 +137,7 @@
direct-store-path
log-file))
-(define %protocol-version #x110)
+(define %protocol-version #x111)
(define %worker-magic-1 #x6e697863) ; "nixc"
(define %worker-magic-2 #x6478696f) ; "dxio"
@@ -938,7 +938,7 @@ is not an atomic operation.) When CHECK-CONTENTS? is true, check the contents
of store items; this can take a lot of time."
(not (verify store check-contents? repair?)))))
-(define (run-gc server action to-delete min-freed)
+(define* (run-gc server action to-delete min-freed #:key (keep-going? #f))
"Perform the garbage-collector operation ACTION, one of the
`gc-action' values. When ACTION is `delete-specific', the TO-DELETE is
the list of store paths to delete. IGNORE-LIVENESS? should always be
@@ -956,6 +956,8 @@ and the number of bytes freed."
;; Obsolete `use-atime' and `max-atime' parameters.
(write-int 0 s)
(write-int 0 s))
+ (when (>= (nix-server-minor-version server) 17)
+ (write-arg boolean keep-going? s))
;; Loop until the server is done sending error output.
(let loop ((done? (process-stderr server)))
@@ -993,12 +995,14 @@ then collect at least MIN-FREED bytes. Return the paths that were
collected, and the number of bytes freed."
(run-gc server (gc-action delete-dead) '() min-freed))
-(define* (delete-paths server paths #:optional (min-freed (%long-long-max)))
+(define* (delete-paths server paths #:optional (min-freed (%long-long-max))
+ #:key (keep-going? #f))
"Delete PATHS from the store at SERVER, if they are no longer
referenced. If MIN-FREED is non-zero, then stop after at least
MIN-FREED bytes have been collected. Return the paths that were
collected, and the number of bytes freed."
- (run-gc server (gc-action delete-specific) paths min-freed))
+ (run-gc server (gc-action delete-specific) paths min-freed
+ #:keep-going? keep-going?))
(define (import-paths server port)
"Import the set of store paths read from PORT into SERVER's store. An error
@@ -662,8 +662,13 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
foreach (PathSet::iterator, i, options.pathsToDelete) {
assertStorePath(*i);
tryToDelete(state, *i);
- if (state.dead.find(*i) == state.dead.end())
+ if (state.dead.find(*i) == state.dead.end()) {
+ if (options.keepGoing) {
+ printMsg(lvlError, format("cannot delete path `%1%' since it is still alive") % *i);
+ } else {
throw Error(format("cannot delete path `%1%' since it is still alive") % *i);
+ }
+ }
}
} else if (options.maxFreed > 0) {
@@ -50,6 +50,9 @@ struct GCOptions
/* Stop after at least `maxFreed' bytes have been freed. */
unsigned long long maxFreed;
+ /* keep going even if some of the paths can not be collected */
+ bool keepGoing;
+
GCOptions();
};
@@ -6,7 +6,7 @@ namespace nix {
#define WORKER_MAGIC_1 0x6e697863
#define WORKER_MAGIC_2 0x6478696f
-#define PROTOCOL_VERSION 0x110
+#define PROTOCOL_VERSION 0x111
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
@@ -526,6 +526,8 @@ static void performOp(bool trusted, unsigned int clientVersion,
readInt(from);
readInt(from);
}
+ if (GET_PROTOCOL_MINOR(clientVersion) >= 17)
+ options.keepGoing = readInt(from) != 0;
GCResults results;