From b73a133bb5bb40274d3870f130ffb41006f26460 Mon Sep 17 00:00:00 2001 From: Blake Erickson <o.blakeerickson@gmail.com> Date: Tue, 10 Dec 2019 18:57:03 -0700 Subject: [PATCH] FIX: Prevent scientific notation in free space check (#8473) It's possibly that when trying to upload a backup the free space check will output scientific notation resulting in an incorrect "There is not enough space on disk" error. The free space check uses the Linux `print` command which could return a number using scientific notation like `1.60459e+10` and when ruby converts it to an integer it will have the value of `1` instead of `16045879296`. Which means even though you have 16GB of free space you could not upload a 1GB backup file. This commit uses the `printf` command instead which allows you to specify that you do not want scientific notation. I'm not sure why this hasn't been an issue before, but I was experiencing it locally in development. --- app/controllers/admin/backups_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/backups_controller.rb b/app/controllers/admin/backups_controller.rb index 9d52e669b5c..3eb3f627720 100644 --- a/app/controllers/admin/backups_controller.rb +++ b/app/controllers/admin/backups_controller.rb @@ -215,7 +215,7 @@ class Admin::BackupsController < Admin::AdminController private def has_enough_space_on_disk?(size) - `df -Pk #{Rails.root}/public/backups | awk 'NR==2 {print $4 * 1024;}'`.to_i > size + `df -Pk #{Rails.root}/public/backups | awk 'NR==2 {printf "%.0f", $4 * 1024;}'`.to_i > size end def ensure_backups_enabled