Skip to content

Commit

Permalink
Improved rake data:fetch and rake db:fetch to use Downloader.
Browse files Browse the repository at this point in the history
  • Loading branch information
igal committed Sep 3, 2010
1 parent 60b5055 commit 1e13bc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
9 changes: 2 additions & 7 deletions lib/tasks/data_marshal.rake
@@ -1,7 +1,7 @@
namespace :data do
task :prepare => [:environment] do
require 'lib/data_marshal'
require 'open-uri'
require 'lib/downloader'
end

desc "Dumps state to FILE, defaults to DBNAME.TIMESTAMP.data"
Expand All @@ -28,12 +28,7 @@ namespace :data do
target = "export.data"

puts "* Downloading #{source}..."
File.open(target, "wb+") do |writer|
# NOTE Do not use File.open, open-uri doesn't intercept URL calls to that
open(source, "rb") do |reader|
writer.write(reader.read)
end
end
Downloader.download(source, target)

puts "* Replacing data..."
DataMarshal.restore(target)
Expand Down
7 changes: 1 addition & 6 deletions lib/tasks/db_fetch.rake
Expand Up @@ -16,12 +16,7 @@ namespace :db do
cp current, backup

puts "Downloading '#{source}' to '#{bn replacement}'..."
open(replacement, "w+") do |writer|
require 'open-uri'
open(source) do |reader|
writer.write(reader.read)
end
end
Downloader.download(source, replacement)

puts "Swapping '#{bn replacement}' to '#{bn current}'..."
mv replacement, current
Expand Down

0 comments on commit 1e13bc7

Please sign in to comment.