]> gitweb.factorcode.org Git - factor.git/commitdiff
http.download: use ``path`` not ``file`` in stack effect
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 26 Mar 2024 22:00:24 +0000 (15:00 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 26 Mar 2024 22:00:24 +0000 (15:00 -0700)
basis/http/download/download-docs.factor
basis/http/download/download.factor

index 76f3a19dc07a7edaa08d4934fc53c2cb7a8e79a4..093ce7b90545b70d707843c3dcb1e82aeaaac5b5 100644 (file)
@@ -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." } ;
index 1d087a07bd471aa3d45b4afa82d318a7493adc64..3f8b2be8ceb4976986a39fd9b349f088007e413b 100644 (file)
@@ -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 )