|
|
|
@ -125,7 +125,25 @@ module Mastodon::CLI
|
|
|
|
|
progress.log("Moving #{previous_path} to #{upgraded_path}") if options[:verbose]
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
unless dry_run?
|
|
|
|
|
move_previous_to_upgraded
|
|
|
|
|
rescue => e
|
|
|
|
|
progress.log(pastel.red("Error processing #{previous_path}: #{e}"))
|
|
|
|
|
success = false
|
|
|
|
|
|
|
|
|
|
remove_directory
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Because we move files style-by-style, it's important to restore
|
|
|
|
|
# previous version at the end. The upgrade will be recorded after
|
|
|
|
|
# all styles are updated
|
|
|
|
|
attachment.instance_write(:storage_schema_version, previous_storage_schema_version)
|
|
|
|
|
success
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def move_previous_to_upgraded(previous_path, upgraded_path)
|
|
|
|
|
return if dry_run?
|
|
|
|
|
|
|
|
|
|
FileUtils.mkdir_p(File.dirname(upgraded_path))
|
|
|
|
|
FileUtils.mv(previous_path, upgraded_path)
|
|
|
|
|
|
|
|
|
@ -135,25 +153,15 @@ module Mastodon::CLI
|
|
|
|
|
# OK
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
progress.log(pastel.red("Error processing #{previous_path}: #{e}"))
|
|
|
|
|
success = false
|
|
|
|
|
|
|
|
|
|
unless dry_run?
|
|
|
|
|
def remove_directory(path)
|
|
|
|
|
return if dry_run?
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
FileUtils.rmdir(File.dirname(upgraded_path), parents: true)
|
|
|
|
|
FileUtils.rmdir(File.dirname(path), parents: true)
|
|
|
|
|
rescue Errno::ENOTEMPTY
|
|
|
|
|
# OK
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Because we move files style-by-style, it's important to restore
|
|
|
|
|
# previous version at the end. The upgrade will be recorded after
|
|
|
|
|
# all styles are updated
|
|
|
|
|
attachment.instance_write(:storage_schema_version, previous_storage_schema_version)
|
|
|
|
|
success
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|