From 586ac29d6f42ad69bcb9772d8364f860cebaedfb Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 26 Mar 2024 15:00:24 -0700 Subject: [PATCH] http.download: use ``path`` not ``file`` in stack effect --- basis/http/download/download-docs.factor | 4 ++-- basis/http/download/download.factor | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/basis/http/download/download-docs.factor b/basis/http/download/download-docs.factor index 76f3a19dc0..093ce7b905 100644 --- a/basis/http/download/download-docs.factor +++ b/basis/http/download/download-docs.factor @@ -11,13 +11,13 @@ HELP: download { $errors "Throws an error if the HTTP request fails." } ; HELP: download-to -{ $values { "url" { $or url string } } { "file" "a pathname string" } { "path" "a pathname string" } } +{ $values { "url" { $or url string } } { "path" "a pathname string" } } { $description "Downloads the contents of the URL to a file with the given pathname and returns the pathname." } { $notes "Use this to download the file every time." } { $errors "Throws an error if the HTTP request fails." } ; HELP: download-once-to -{ $values { "url" { $or url string } } { "file" "a pathname string" } { "path" "a pathname string" } } +{ $values { "url" { $or url string } } { "path" "a pathname string" } } { $description "If the file exists on disk, returns that pathname without downloading anything. Otherwise, downloads the contents of the URL to a file with the given pathname and returns the pathname." } { $notes "Use this if the contents of the URL are not expected to change." } { $errors "Throws an error if the HTTP request fails." } ; diff --git a/basis/http/download/download.factor b/basis/http/download/download.factor index 1d087a07bd..3f8b2be8ce 100644 --- a/basis/http/download/download.factor +++ b/basis/http/download/download.factor @@ -7,18 +7,18 @@ math.order math.parser present sequences shuffle splitting ; IN: http.download -: file-too-old-or-not-exists? ( file duration -- ? ) +: file-too-old-or-not-exists? ( path duration -- ? ) [ ?file-info [ created>> ] ?call ] [ ago ] bi* over [ before? ] [ 2drop t ] if ; -: delete-when-old ( file duration -- deleted? ) +: delete-when-old ( path duration -- deleted? ) dupd file-too-old-or-not-exists? [ ?delete-file t ] [ drop f ] if ; -: file-matches-checksum? ( file checksum-type bytes -- ? ) +: file-matches-checksum? ( path checksum-type bytes -- ? ) [ checksum-file ] dip = ; -: delete-when-checksum-mismatches ( file checksum-type bytes -- deleted? ) +: delete-when-checksum-mismatches ( path checksum-type bytes -- deleted? ) dupdd file-matches-checksum? [ drop f ] [ ?delete-file t ] if ; : file-size= ( path n -- ? ) [ ?file-info [ size>> ] ?call ] dip = ; @@ -32,7 +32,7 @@ IN: http.download drop t ] if ; -: delete-when-file-size-mismatches? ( file size -- deleted? ) +: delete-when-file-size-mismatches? ( path size -- deleted? ) dupd file-size= [ drop f ] [ ?delete-file t ] if ; : download-name ( url -- name ) @@ -84,19 +84,19 @@ IN: http.download PRIVATE> -: download-to ( url file -- path ) +: download-to ( url path -- path ) [ [ download-temporary-name binary ] keep '[ _ http-write-request ] with-unique-file-writer ] dip [ move-file ] keep ; -: download-once-to ( url file -- path ) +: download-once-to ( url path -- path ) dup file-exists? [ nip ] [ download-to ] if ; : download-once ( url -- path ) dup download-name download-once-to ; -: download-outdated-to ( url file duration -- path ) +: download-outdated-to ( url path duration -- path ) 2dup delete-when-old [ drop download-to ] [ drop nip ] if ; : download ( url -- path ) -- 2.34.1