diff options
| author | mo khan <mo@mokhan.ca> | 2014-09-22 19:50:24 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-09-22 19:50:24 -0600 |
| commit | 5dfbb2fc806023eceb6cfca0597cff3d55c9e6f7 (patch) | |
| tree | 6086c95c62fc53816282b17a98bb63a4cca05060 /script | |
| parent | 643c57c0fdd4f7a1aa61755ca21268a87c68e8ee (diff) | |
add a bit of console output and add missing create tmp dir method.
Diffstat (limited to 'script')
| -rw-r--r-- | script/migrate-photos.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/script/migrate-photos.rb b/script/migrate-photos.rb index bcc42f32..f41e28b9 100644 --- a/script/migrate-photos.rb +++ b/script/migrate-photos.rb @@ -11,12 +11,18 @@ class Command def run Photo.find_each do |photo| - original = OriginalVersion.new(photo) - storage.download(original.create_key) do |file| - message_bus.publish(:upload_photo, { - photo_id: photo.id, - file_path: move_to_temporary_storage(file.path, File.basename(original.create_key)) - }) + begin + original = OriginalVersion.new(photo) + key = original.create_key + puts "processing #{key}" + storage.download(key) do |file| + bus.publish(:upload_photo, { + photo_id: photo.id, + file_path: move_to_temporary_storage(file.path, File.basename(key)) + }) + end + rescue StandardError => error + puts error.message end end end @@ -28,6 +34,12 @@ class Command FileUtils.mv(temp_file_path, new_path) end end + + def create_tmp_dir + Rails.root.join("tmp/uploads/#{SecureRandom.uuid}").tap do |directory| + system "mkdir -p #{directory}" + end + end end Command.new.run |
