FIX: correct upload statistics report for external storage

Follows up #64b35120

This also corrects it so bytes used for internal storage counts all the space
used, previously it was only counting uploads not optimized images.

Additionally we now correctly count storage for optimized images.
This commit is contained in:
Sam Saffron 2020-02-20 15:15:34 +11:00
parent 254b57c812
commit a3d576534a
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
1 changed files with 10 additions and 4 deletions

View File

@ -2,13 +2,19 @@
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
if Discourse.store.external?
Upload.sum(:filesize).to_i + OptimizedImage.sum(:filesize).to_i
else
used(uploads_path)
end
end
def self.uploads_free_bytes
free(uploads_path)
if Discourse.store.external?
0
else
free(uploads_path)
end
end
def self.free(path)