* [PATCH] utils: file-extension should work with urls.
@ 2016-12-14 15:25 David Craven
2016-12-14 15:26 ` David Craven
0 siblings, 1 reply; 4+ messages in thread
From: David Craven @ 2016-12-14 15:25 UTC (permalink / raw)
To: guix-devel
* guix/utils.scm (file-extension): Detect the lack of file extensions in
urls.
---
guix/utils.scm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/guix/utils.scm b/guix/utils.scm
index 06f49daca..2bae2eb60 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -24,6 +24,7 @@
(define-module (guix utils)
#:use-module (guix config)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-2)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
@@ -559,8 +560,11 @@ minor version numbers from version-string."
(define (file-extension file)
"Return the extension of FILE or #f if there is none."
- (let ((dot (string-rindex file #\.)))
- (and dot (substring file (+ 1 dot) (string-length file)))))
+ (and-let* ((dot (string-rindex file #\.))
+ (ext (substring file (+ 1 dot) (string-length file))))
+ ;; Make sure that a file-extension does not contain forward
+ ;; slashes incase file is a URL.
+ (and (not (string-rindex file #\/)) ext)))
(define (file-sans-extension file)
"Return the substring of FILE without its extension, if any."
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] utils: file-extension should work with urls.
2016-12-14 15:25 [PATCH] utils: file-extension should work with urls David Craven
@ 2016-12-14 15:26 ` David Craven
2016-12-15 4:27 ` David Craven
0 siblings, 1 reply; 4+ messages in thread
From: David Craven @ 2016-12-14 15:26 UTC (permalink / raw)
To: guix-devel
This patch causes a test failure. Any ideas on how to do it better?
I'll push the rust stuff in the meantime, since there is nothing
technically wrong with the updater itself.
test-name: /*.narinfo for a compressed file
location: /home/dvc/guix/tests/publish.scm:218
source:
+ (test-equal
+ "/*.narinfo for a compressed file"
+ '("none" "nar")
+ (let* ((item (add-text-to-store
+ %store
+ "fake.tar.gz"
+ "This is a fake compressed file."))
+ (url (string-append
+ "http://localhost:6799/"
+ (store-path-hash-part item)
+ ".narinfo"))
+ (body (http-get-port url))
+ (info (recutils->alist body)))
+ (list (assoc-ref info "Compression")
+ (dirname (assoc-ref info "URL")))))
expected-value: (none nar)
actual-value: (gzip nar/gzip)
result: FAIL
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] utils: file-extension should work with urls.
2016-12-14 15:26 ` David Craven
@ 2016-12-15 4:27 ` David Craven
2016-12-15 5:01 ` David Craven
0 siblings, 1 reply; 4+ messages in thread
From: David Craven @ 2016-12-15 4:27 UTC (permalink / raw)
To: guix-devel
> guix/utils.scm (file-extension): Detect the lack of file extensions in urls.
This is so stupid. Just to cover up some other stupidity I did earlier that day.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] utils: file-extension should work with urls.
2016-12-15 4:27 ` David Craven
@ 2016-12-15 5:01 ` David Craven
0 siblings, 0 replies; 4+ messages in thread
From: David Craven @ 2016-12-15 5:01 UTC (permalink / raw)
To: guix-devel
Fixed yesterdays stupidity with 6976c68158e9c6bb264ca48041da5be1c24521cf
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-15 5:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 15:25 [PATCH] utils: file-extension should work with urls David Craven
2016-12-14 15:26 ` David Craven
2016-12-15 4:27 ` David Craven
2016-12-15 5:01 ` David Craven
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).