mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: warn the user when there is not enough space on disk to upload a backup
This commit is contained in:
@@ -100,14 +100,16 @@ class Admin::BackupsController < Admin::AdminController
|
||||
end
|
||||
|
||||
def upload_chunk
|
||||
filename = params.fetch(:resumableFilename)
|
||||
return render nothing:true, status: 415 unless filename.to_s.end_with?(".tar.gz")
|
||||
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.not_enough_space_on_disk") unless has_enough_space_on_disk?(total_size)
|
||||
|
||||
file = params.fetch(:file)
|
||||
identifier = params.fetch(:resumableIdentifier)
|
||||
chunk_number = params.fetch(:resumableChunkNumber).to_i
|
||||
chunk_size = params.fetch(:resumableChunkSize).to_i
|
||||
total_size = params.fetch(:resumableTotalSize).to_i
|
||||
current_chunk_size = params.fetch(:resumableCurrentChunkSize).to_i
|
||||
|
||||
# path to chunk file
|
||||
@@ -130,4 +132,10 @@ class Admin::BackupsController < Admin::AdminController
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def has_enough_space_on_disk?(size)
|
||||
`df -l . | tail -1 | tr -s ' ' | cut -d ' ' -f 4`.to_i > size
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user