diff options
author | Mario Domenech Goulart <mario@parenteses.org> | 2021-06-14 19:38:50 +0200 |
---|---|---|
committer | Peter Bex <peter@more-magic.net> | 2021-06-15 06:53:48 +0200 |
commit | 8abfaf2c5744b12e3e47dd4e1abc92ac44dc2309 (patch) | |
tree | 27cb7d1cf3b22acaf2ee9ea0cd4f2b0fe85cffba /henrietta-cache.scm | |
parent | ca025567fd77e094ad86be09709e7b42861392d3 (diff) | |
download | henrietta-cache-8abfaf2c5744b12e3e47dd4e1abc92ac44dc2309.tar.gz |
Handle symlinks first when moving files to cache
When moving files from the temporary directory to the cache directory,
we must handle symlinks first. If we handle the _target_ before the
symlink, the target will be deleted and `copy-file' will break when
trying to copy the symlink, as it will be dangling.
Signed-off-by: Peter Bex <peter@more-magic.net>
Diffstat (limited to 'henrietta-cache.scm')
-rw-r--r-- | henrietta-cache.scm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/henrietta-cache.scm b/henrietta-cache.scm index 023e16a..ae5c449 100644 --- a/henrietta-cache.scm +++ b/henrietta-cache.scm @@ -13,7 +13,7 @@ (chicken format) (chicken string) (chicken port) (chicken process) (chicken process-context) (chicken pathname) (chicken io) (chicken sort) - (chicken irregex) + (chicken irregex) (chicken file posix) http-client matchable uri-common srfi-1))) (define (usage code) @@ -125,7 +125,13 @@ EOF (begin (copy-file tmp-file cache-file) (delete-file tmp-file) )))) - (directory tmp-dir #t) ) + ;; Here we have to handle symlinks first. If we handle the + ;; _target_ before the symlink, target will be deleted and + ;; `copy-file' will break when trying to copy the symlink, as it + ;; will be dangling. + (sort (directory tmp-dir #t) + (lambda (f _) + (symbolic-link? (make-pathname tmp-dir f))))) (delete-directory tmp-dir #t) ) ;nb: don't like recursive but top level has hidden contents and don't want those (define (download-files-from-list base-uri files cache-dir) |