mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 15:13:43 +08:00
1a8ca68ea3
* Dashboard doesn't timeout anymore when Amazon S3 is used for backups * Storage stats are now a proper report with the same caching rules * Changing the backup_location, s3_backup_bucket or creating and deleting backups removes the report from the cache * It shows the number of backups and the backup location * It shows the used space for the correct backup location instead of always showing used space on local storage * It shows the date of the last backup as relative date
25 lines
544 B
Ruby
25 lines
544 B
Ruby
class DiskSpace
|
|
def self.uploads_used_bytes
|
|
# used(uploads_path)
|
|
# temporary (on our internal setup its just too slow to iterate)
|
|
Upload.sum(:filesize).to_i
|
|
end
|
|
|
|
def self.uploads_free_bytes
|
|
free(uploads_path)
|
|
end
|
|
|
|
def self.free(path)
|
|
`df -Pk #{path} | awk 'NR==2 {print $4;}'`.to_i * 1024
|
|
end
|
|
|
|
def self.used(path)
|
|
`du -s #{path}`.to_i * 1024
|
|
end
|
|
|
|
def self.uploads_path
|
|
"#{Rails.root}/public/uploads/#{RailsMultisite::ConnectionManagement.current_db}"
|
|
end
|
|
private_class_method :uploads_path
|
|
end
|