store: Change 'export-paths' to always export in topological order.
* guix/store.scm (export-paths): Pass PATHS through 'topologically-sorted' before iterating. * tests/store.scm ("export/import paths, ensure topological order"): New test.master
parent
829b1b253e
commit
99fbddf9a6
|
@ -732,10 +732,10 @@ is raised if the set of paths read from PORT is not signed (as per
|
||||||
(= 1 (read-int s))))
|
(= 1 (read-int s))))
|
||||||
|
|
||||||
(define* (export-paths server paths port #:key (sign? #t))
|
(define* (export-paths server paths port #:key (sign? #t))
|
||||||
"Export the store paths listed in PATHS to PORT, signing them if SIGN?
|
"Export the store paths listed in PATHS to PORT, in topological order,
|
||||||
is true."
|
signing them if SIGN? is true."
|
||||||
(let ((s (nix-server-socket server)))
|
(let ((s (nix-server-socket server)))
|
||||||
(let loop ((paths paths))
|
(let loop ((paths (topologically-sorted server paths)))
|
||||||
(match paths
|
(match paths
|
||||||
(()
|
(()
|
||||||
(write-int 0 port))
|
(write-int 0 port))
|
||||||
|
|
|
@ -398,6 +398,25 @@ Deriver: ~a~%"
|
||||||
get-string-all))
|
get-string-all))
|
||||||
files)))))))
|
files)))))))
|
||||||
|
|
||||||
|
(test-assert "export/import paths, ensure topological order"
|
||||||
|
(let* ((file1 (add-text-to-store %store "foo" (random-text)))
|
||||||
|
(file2 (add-text-to-store %store "bar" (random-text)
|
||||||
|
(list file1)))
|
||||||
|
(files (list file1 file2))
|
||||||
|
(dump1 (call-with-bytevector-output-port
|
||||||
|
(cute export-paths %store (list file1 file2) <>)))
|
||||||
|
(dump2 (call-with-bytevector-output-port
|
||||||
|
(cute export-paths %store (list file2 file1) <>))))
|
||||||
|
(delete-paths %store files)
|
||||||
|
(and (every (negate file-exists?) files)
|
||||||
|
(bytevector=? dump1 dump2)
|
||||||
|
(let* ((source (open-bytevector-input-port dump1))
|
||||||
|
(imported (import-paths %store source)))
|
||||||
|
(and (equal? imported (list file1 file2))
|
||||||
|
(every file-exists? files)
|
||||||
|
(null? (references %store file1))
|
||||||
|
(equal? (list file1) (references %store file2)))))))
|
||||||
|
|
||||||
(test-assert "import corrupt path"
|
(test-assert "import corrupt path"
|
||||||
(let* ((text (random-text))
|
(let* ((text (random-text))
|
||||||
(file (add-text-to-store %store "text" text))
|
(file (add-text-to-store %store "text" text))
|
||||||
|
|
Reference in New Issue