[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/02: daemon: Read unsigned nar size and download size from substituter
From: |
guix-commits |
Subject: |
01/02: daemon: Read unsigned nar size and download size from substituter. |
Date: |
Wed, 24 Nov 2021 18:20:00 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 1eb40a6dc4917f5a2e915f8b31b750dba3d378c6
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Nov 24 22:58:12 2021 +0100
daemon: Read unsigned nar size and download size from substituter.
Fixes <https://issues.guix.gnu.org/51983>.
Reported by Tobias Geerinckx-Rice <me@tobias.gr>.
* nix/libstore/local-store.cc (LocalStore::querySubstitutablePathInfos):
Expect 'unsigned long long' for 'downloadSize' and 'narSize'.
* tests/store.scm ("substitute query and large size"): New test.
---
nix/libstore/local-store.cc | 4 ++--
tests/store.scm | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc
index 675d1ba..d52b102 100644
--- a/nix/libstore/local-store.cc
+++ b/nix/libstore/local-store.cc
@@ -907,8 +907,8 @@ void LocalStore::querySubstitutablePathInfos(PathSet &
paths, SubstitutablePathI
assertStorePath(p);
info.references.insert(p);
}
- info.downloadSize = getIntLineFromSubstituter<long long>(run);
- info.narSize = getIntLineFromSubstituter<long long>(run);
+ info.downloadSize = getIntLineFromSubstituter<unsigned long long>(run);
+ info.narSize = getIntLineFromSubstituter<unsigned long long>(run);
}
}
diff --git a/tests/store.scm b/tests/store.scm
index 5c9f651..11ca440 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -942,6 +942,40 @@
(build-derivations s (list d))
#f))))))
+(test-equal "substitute query and large size"
+ (+ 100 (expt 2 63)) ;<https://issues.guix.gnu.org/51983>
+ (with-store s
+ (let* ((size (+ 100 (expt 2 63))) ;does not fit in signed 'long long'
+ (item (string-append (%store-prefix)
+ "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bad-size")))
+ ;; Create fake substituter data, to be read by 'guix substitute'.
+ (call-with-output-file (string-append (%substitute-directory)
+ "/" (store-path-hash-part item)
+ ".narinfo")
+ (lambda (port)
+ (format port "StorePath: ~a
+URL: http://example.org
+Compression: none
+NarSize: ~a
+NarHash: sha256:0fj9vhblff2997pi7qjj7lhmy7wzhnjwmkm2hmq6gr4fzmg10s0w
+References:
+System: x86_64-linux~%"
+ item size)))
+
+ ;; Remove entry from the local cache.
+ (false-if-exception
+ (delete-file-recursively (string-append (getenv "XDG_CACHE_HOME")
+ "/guix/substitute")))
+
+ ;; Make sure 'guix substitute' correctly communicates the above
+ ;; data.
+ (set-build-options s #:use-substitutes? #t
+ #:substitute-urls (%test-substitute-urls))
+ (match (pk 'spi (substitutable-path-info s (list item)))
+ (((? substitutable? s))
+ (and (equal? (substitutable-path s) item)
+ (substitutable-nar-size s)))))))
+
(test-assert "export/import several paths"
(let* ((texts (unfold (cut >= <> 10)
(lambda _ (random-text))