accounts: Close database before renaming it.
authorLudovic Courtès <ludo@gnu.org>
Wed, 5 Jun 2019 09:12:21 +0000 (11:12 +0200)
committerLudovic Courtès <ludo@gnu.org>
Wed, 5 Jun 2019 21:10:37 +0000 (23:10 +0200)
Fixes <https://bugs.gnu.org/35996>.
Reported by Florian Pelz <pelzflorian@pelzflorian.de>.

* gnu/build/accounts.scm (database-writer): Move 'close-port' call
before 'rename-file'.

gnu/build/accounts.scm

index 8687446..2120c1d 100644 (file)
@@ -249,9 +249,11 @@ to it atomically and set the appropriate permissions."
             (lambda ()
               (chmod port mode)
               (write-entries port)
+              (close-port port)
               (rename-file template file-or-port))
             (lambda ()
-              (close-port port)
+              (unless (port-closed? port)
+                (close-port port))
               (when (file-exists? template)
                 (delete-file template))))))))