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))))))
(define (call-with-writable-file file thunk)
(let ((stat (lstat file)))
(dynamic-wind
(lambda ()
(make-file-writable file))
thunk
(lambda ()
(set-file-time file stat)
(chmod file (stat:mode stat))))))
(if (string=? file (%store-directory))
(thunk) ;don't meddle with the store's permissions
(let ((stat (lstat file)))
(dynamic-wind
(lambda ()
(make-file-writable file))
thunk
(lambda ()
(set-file-time file stat)
(chmod file (stat:mode stat)))))))
(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 ...)))
;; There are 3 main kinds of errors we can get from hardlinking: "Too many