FIX: add support for 'space' in backup's filename

This commit is contained in:
Régis Hanol 2016-04-04 17:24:02 +02:00
parent 79639e2dec
commit 332a1ea87e
2 changed files with 7 additions and 7 deletions

View File

@ -9,7 +9,7 @@ require_dependency "permalink_constraint"
# and makes Guard not work properly.
USERNAME_ROUTE_FORMAT = /[\w.\-]+/ unless defined? USERNAME_ROUTE_FORMAT
BACKUP_ROUTE_FORMAT = /[\w.\-]+\.(tar\.gz|tgz)/i unless defined? BACKUP_ROUTE_FORMAT
BACKUP_ROUTE_FORMAT = /.+\.(tar\.gz|tgz)/i unless defined? BACKUP_ROUTE_FORMAT
Discourse::Application.routes.draw do

View File

@ -157,17 +157,17 @@ module BackupRestore
def copy_archive_to_tmp_directory
log "Copying archive to tmp directory..."
source = File.join(Backup.base_directory, @filename)
`cp #{source} #{@archive_filename}`
`cp '#{source}' '#{@archive_filename}'`
end
def unzip_archive
log "Unzipping archive..."
FileUtils.cd(@tmp_directory) { `gzip --decompress #{@archive_filename}` }
FileUtils.cd(@tmp_directory) { `gzip --decompress '#{@archive_filename}'` }
end
def extract_metadata
log "Extracting metadata file..."
FileUtils.cd(@tmp_directory) { `tar --extract --file #{@tar_filename} #{BackupRestore::METADATA_FILE}` }
FileUtils.cd(@tmp_directory) { `tar --extract --file '#{@tar_filename}' #{BackupRestore::METADATA_FILE}` }
@metadata = Oj.load_file(@meta_filename)
end
@ -182,7 +182,7 @@ module BackupRestore
def extract_dump
log "Extracting dump file..."
FileUtils.cd(@tmp_directory) { `tar --extract --file #{@tar_filename} #{BackupRestore::DUMP_FILE}` }
FileUtils.cd(@tmp_directory) { `tar --extract --file '#{@tar_filename}' #{BackupRestore::DUMP_FILE}` }
end
def restore_dump
@ -275,10 +275,10 @@ module BackupRestore
end
def extract_uploads
if `tar --list --file #{@tar_filename} | grep 'uploads/'`.present?
if `tar --list --file '#{@tar_filename}' | grep 'uploads/'`.present?
log "Extracting uploads..."
FileUtils.cd(File.join(Rails.root, "public")) do
`tar --extract --keep-newer-files --file #{@tar_filename} uploads/`
`tar --extract --keep-newer-files --file '#{@tar_filename}' uploads/`
end
end
end