deduplication: Leave the store permissions unchanged.

Suggested by Caleb Ristvedt <caleb.ristvedt@cune.org>.

* guix/store/deduplication.scm (call-with-writable-file): Call THUNK
directly when FILE is (%store-directory).
This commit is contained in:
Ludovic Courtès 2020-06-25 10:18:17 +02:00
parent 6b654a3332
commit 3b7145d821
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 12 additions and 9 deletions

View File

@ -95,17 +95,20 @@ LINK-PREFIX."
(apply throw args)))))) (apply throw args))))))
(define (call-with-writable-file file thunk) (define (call-with-writable-file file thunk)
(let ((stat (lstat file))) (if (string=? file (%store-directory))
(dynamic-wind (thunk) ;don't meddle with the store's permissions
(lambda () (let ((stat (lstat file)))
(make-file-writable file)) (dynamic-wind
thunk (lambda ()
(lambda () (make-file-writable file))
(set-file-time file stat) thunk
(chmod file (stat:mode stat)))))) (lambda ()
(set-file-time file stat)
(chmod file (stat:mode stat)))))))
(define-syntax-rule (with-writable-file file exp ...) (define-syntax-rule (with-writable-file file exp ...)
"Make FILE writable for the dynamic extent of EXP..." "Make FILE writable for the dynamic extent of EXP..., except if FILE is the
store."
(call-with-writable-file file (lambda () exp ...))) (call-with-writable-file file (lambda () exp ...)))
;; There are 3 main kinds of errors we can get from hardlinking: "Too many ;; There are 3 main kinds of errors we can get from hardlinking: "Too many