FIX: Raise or log error when deleting of backup fails
This commit is contained in:
parent
868528f862
commit
c94a2bc69b
|
@ -256,9 +256,6 @@ module BackupRestore
|
|||
content_type = MiniMime.lookup_by_filename(@backup_filename).content_type
|
||||
archive_path = File.join(@archive_directory, @backup_filename)
|
||||
@store.upload_file(@backup_filename, archive_path, content_type)
|
||||
ensure
|
||||
log "Removing archive from local storage..."
|
||||
FileUtils.remove_file(archive_path, force: true)
|
||||
end
|
||||
|
||||
def after_create_hook
|
||||
|
@ -294,6 +291,7 @@ module BackupRestore
|
|||
|
||||
def clean_up
|
||||
log "Cleaning stuff up..."
|
||||
delete_uploaded_archive
|
||||
remove_tar_leftovers
|
||||
unpause_sidekiq
|
||||
disable_readonly_mode if Discourse.readonly_mode?
|
||||
|
@ -301,6 +299,19 @@ module BackupRestore
|
|||
refresh_disk_space
|
||||
end
|
||||
|
||||
def delete_uploaded_archive
|
||||
return unless @store.remote?
|
||||
|
||||
archive_path = File.join(@archive_directory, @backup_filename)
|
||||
|
||||
if File.exist?(archive_path)
|
||||
log "Removing archive from local storage..."
|
||||
File.delete(archive_path)
|
||||
end
|
||||
rescue => ex
|
||||
log "Something went wrong while deleting uploaded archive from local storage.", ex
|
||||
end
|
||||
|
||||
def refresh_disk_space
|
||||
log "Refreshing disk stats..."
|
||||
@store.reset_cache
|
||||
|
|
|
@ -33,7 +33,7 @@ module BackupRestore
|
|||
path = path_from_filename(filename)
|
||||
|
||||
if File.exists?(path)
|
||||
FileUtils.remove_file(path, force: true)
|
||||
File.delete(path)
|
||||
reset_cache
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue