FIX: add support for .tgz and .gz backup files

This commit is contained in:
Régis Hanol 2015-04-07 15:26:47 +02:00
parent 266f3d677d
commit babbbc06d1
3 changed files with 3 additions and 3 deletions

View File

@ -110,7 +110,7 @@ class Admin::BackupsController < Admin::AdminController
filename = params.fetch(:resumableFilename) filename = params.fetch(:resumableFilename)
total_size = params.fetch(:resumableTotalSize).to_i total_size = params.fetch(:resumableTotalSize).to_i
return render status: 415, text: I18n.t("backup.backup_file_should_be_tar_gz") unless filename.to_s.end_with?(".tar.gz") return render status: 415, text: I18n.t("backup.backup_file_should_be_tar_gz") unless /\.(tar\.gz|t?gz)$/i =~ filename
return render status: 415, text: I18n.t("backup.not_enough_space_on_disk") unless has_enough_space_on_disk?(total_size) return render status: 415, text: I18n.t("backup.not_enough_space_on_disk") unless has_enough_space_on_disk?(total_size)
file = params.fetch(:file) file = params.fetch(:file)

View File

@ -10,7 +10,7 @@ class Backup
end end
def self.all def self.all
Dir.glob(File.join(Backup.base_directory, "*.tar.gz")) Dir.glob(File.join(Backup.base_directory, "*.{gz,tgz}"))
.sort_by { |file| File.mtime(file) } .sort_by { |file| File.mtime(file) }
.reverse .reverse
.map { |backup| Backup.create_from_filename(File.basename(backup)) } .map { |backup| Backup.create_from_filename(File.basename(backup)) }

View File

@ -8,7 +8,7 @@ require_dependency "permalink_constraint"
# This used to be User#username_format, but that causes a preload of the User object # This used to be User#username_format, but that causes a preload of the User object
# and makes Guard not work properly. # and makes Guard not work properly.
USERNAME_ROUTE_FORMAT = /[A-Za-z0-9\_]+/ unless defined? USERNAME_ROUTE_FORMAT USERNAME_ROUTE_FORMAT = /[A-Za-z0-9\_]+/ unless defined? USERNAME_ROUTE_FORMAT
BACKUP_ROUTE_FORMAT = /[a-zA-Z0-9\-_]*\d{4}(-\d{2}){2}-\d{6}\.tar\.gz/i unless defined? BACKUP_ROUTE_FORMAT BACKUP_ROUTE_FORMAT = /[a-zA-Z0-9\-_]*\d{4}(-\d{2}){2}-\d{6}\.(tar\.gz|t?gz)/i unless defined? BACKUP_ROUTE_FORMAT
Discourse::Application.routes.draw do Discourse::Application.routes.draw do