Fixes <http://bugs.gnu.org/19756>.
Reported by <sleep_walker@suse.cz>.
* guix/serialization.scm (currently-restored-file): New variable.
(get-bytevector-n*): New procedure.
(read-int, read-long-long, read-string, read-latin1-string,
read-contents): Use it instead of 'get-bytevector-n'.
(restore-file): Parameterize 'currently-restored-file' and set it.
* tests/nar.scm ("restore-file with incomplete input"): New test.
Fixes <http://bugs.gnu.org/18935>.
Reported by Mark H Weaver <mhw@netris.org>.
Previously, if tests/nar.scm ran concurrently with tests/gexp.scm, the
store item "foo" containing the string "Hello, world!" could be
deleted (via 'delete-paths') from the tests/nar.scm daemon while the
tests/gexp.scm daemon would still consider it live.
* tests/nar.scm ("restore-file-set (missing signature)"):
Use (random-text) rather than "Hello, world!", to avoid concurrent
deletion of store item "foo" used in tests/gexp.scm.
* guix/nar.scm (write-file) <directory>: Pass 'string<?' as the second
argument to 'scandir'.
* tests/nar.scm ("write-file puts file in C locale collation order"):
New test.
* guix/nar.scm (write-file): Add case for type `symlink'.
(restore-file): Likewise.
* tests/nar.scm (random-file-size, make-file-tree, delete-file-tree,
with-file-tree, file-tree-equal?, make-random-bytevector,
populate-file): New procedures.
(%test-dir): New variable.
("write-file + restore-file"): Use `%test-dir' and `file-tree-equal?'.
("write-file + restore-file with symlinks"): New test.
* guix/nar.scm (&nar-error, &nar-read-error): New condition types.
(dump): New procedure.
(write-contents)[dump]: Remove. Use the one above instead.
(read-contents, write-file, restore-file): New procedures.
(%archive-version-1): New variable.