FIX: tar --list against a .tar.gz file takes too long.

This resulted in requests being blocked for an extended amount
of time when initializing the restorer.
This commit is contained in:
Guo Xiang Tan 2016-09-16 16:59:22 +08:00
parent a04dadf9b4
commit 0bf7519a8a

View File

@ -114,18 +114,6 @@ module BackupRestore
@meta_filename = File.join(@tmp_directory, BackupRestore::METADATA_FILE)
@is_archive = !(@filename =~ /.sql.gz$/)
# For backwards compatibility
@dump_filename =
if @is_archive
if system('tar', '--list', '--file', @source_filename, BackupRestore::OLD_DUMP_FILE)
File.join(@tmp_directory, BackupRestore::OLD_DUMP_FILE)
else
File.join(@tmp_directory, BackupRestore::DUMP_FILE)
end
else
File.join(@tmp_directory, @filename)
end
@logs = []
@readonly_mode_was_enabled = Discourse.readonly_mode?
end
@ -195,7 +183,7 @@ module BackupRestore
log "Extracting metadata file..."
@metadata =
if system('tar', '--list', '--file', @source_filename, BackupRestore::METADATA_FILE)
if system('tar', '--list', '--file', @tar_filename, BackupRestore::METADATA_FILE)
FileUtils.cd(@tmp_directory) do
execute_command(
'tar', '--extract', '--file', @tar_filename, BackupRestore::METADATA_FILE,
@ -228,6 +216,18 @@ module BackupRestore
end
def extract_dump
@dump_filename =
if @is_archive
# For backwards compatibility
if system('tar', '--list', '--file', @tar_filename, BackupRestore::OLD_DUMP_FILE)
File.join(@tmp_directory, BackupRestore::OLD_DUMP_FILE)
else
File.join(@tmp_directory, BackupRestore::DUMP_FILE)
end
else
File.join(@tmp_directory, @filename)
end
return unless @is_archive
log "Extracting dump file..."