diff options
Diffstat (limited to '')
-rwxr-xr-x | home/scripts/sync.scm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/home/scripts/sync.scm b/home/scripts/sync.scm new file mode 100755 index 0000000..a51b557 --- /dev/null +++ b/home/scripts/sync.scm @@ -0,0 +1,28 @@ +#!/usr/bin/env gosh + +;; download the given files to ~/.cache/feedsync under hashed filenames +;; if the versions there are older than two hours + +(use util.match) +(use gauche.process) + + +(define targets + (cdr (command-line))) + +(define cachedir + (string-append (sys-getenv "HOME") "/.cache/feedsync")) + +(do-process `("mkdir" "-p" ,cachedir)) + +(map (lambda (target) + (let ([cachefile (format "~a/~a.ics" cachedir (portable-hash target 0))]) + (cond + [(not (file-exists? cachefile)) + (do-process `("curl" ,target "-o" ,cachefile))] + [(< 7200 (- (sys-time) (sys-stat->mtime (sys-stat cachefile)))) + (print (format "fetching ~a" target)) + (do-process `("curl" ,target "-o" ,cachefile))] + [else + (display "time limit not yet exceeded")]))) + targets) |