diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2010-09-12 02:44:27 -0400 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2010-09-12 02:44:27 -0400 |
| commit | 53772f312235b0a8743c94287b2a7417e8fd42a0 (patch) | |
| tree | 1bef161e76b921df44bf3d5946f6f499ae7caba0 /src/imgreplacer.clj | |
| parent | a76efac353b0362a980873d3a0e3eda0fe0a73c7 (diff) | |
imgreplace adds timestamp to replaced files
Diffstat (limited to 'src/imgreplacer.clj')
| -rw-r--r-- | src/imgreplacer.clj | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/imgreplacer.clj b/src/imgreplacer.clj index 4963e02..fe316c7 100644 --- a/src/imgreplacer.clj +++ b/src/imgreplacer.clj @@ -32,11 +32,14 @@ (reduce (fn [s [k v]] (.replaceAll s k v)) string replacements)) +(defn image-name [url] + (format "%s-%s" (System/currentTimeMillis) (last (.split url "/")))) + (defn mirror-image [url] (println "fetching" url) (let [bytes (to-byte-array (.openStream (URL. url))) date (today) - fname (last (.split url "/")) + fname (image-name url) file (File. (file-path date fname)) img (ImageIO/read (ByteArrayInputStream. bytes))] (make-parents file) |
