From babbbc06d1535affce6b5e0280332eb2f28ee542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 7 Apr 2015 15:26:47 +0200 Subject: [PATCH] FIX: add support for .tgz and .gz backup files --- app/controllers/admin/backups_controller.rb | 2 +- app/models/backup.rb | 2 +- config/routes.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/backups_controller.rb b/app/controllers/admin/backups_controller.rb index a80e1b924d4..83587ac3bb9 100644 --- a/app/controllers/admin/backups_controller.rb +++ b/app/controllers/admin/backups_controller.rb @@ -110,7 +110,7 @@ class Admin::BackupsController < Admin::AdminController filename = params.fetch(:resumableFilename) 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) file = params.fetch(:file) diff --git a/app/models/backup.rb b/app/models/backup.rb index 8b2b27d8064..c143eeb10c7 100644 --- a/app/models/backup.rb +++ b/app/models/backup.rb @@ -10,7 +10,7 @@ class Backup end 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) } .reverse .map { |backup| Backup.create_from_filename(File.basename(backup)) } diff --git a/config/routes.rb b/config/routes.rb index ebac63bacfd..731838d2e70 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ require_dependency "permalink_constraint" # This used to be User#username_format, but that causes a preload of the User object # and makes Guard not work properly. 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