-
-
Save coderanger/08e93d2f03bd4e875264 to your computer and use it in GitHub Desktop.
Example of using http_request to only download files if the mtime changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remote = "http://couchdb.apache.org/img/sketch.png" | |
local = "/tmp/couch.png" | |
remote_file local do | |
source remote | |
action :nothing | |
end | |
http_request "HEAD #{remote}" do | |
message "" | |
url remote | |
action :head | |
if File.exists?(local) | |
headers "If-Modified-Since" => File.mtime(local).httpdate | |
end | |
notifies :create, resources(:remote_file => local), :immediately | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment