Skip to content

Commit

Permalink
add quota setting to env
Browse files Browse the repository at this point in the history
  • Loading branch information
jeriox committed Oct 21, 2024
1 parent bba2c7d commit 693e387
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/admin/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ Data storage and Logging
Defaults to `PRIVATE_DIR/media`.
You should backup this folder regularly.

`MEDIA_FILES_DISK_QUOTA`:
Quota in MB that is enforced for the media files. Defaults to 0, meaning no quota is enforced.

`LOG_DIR`:
Path to the folder where log files are put. Files inside are rotated daily.
Defaults to `PRIVATE_DIR/logs`.
Expand Down
4 changes: 3 additions & 1 deletion ephios/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ def GET_USERCONTENT_URL():
def GET_USERCONTENT_QUOTA():
"""Returns a tuple (used, free) of the user content quota in bytes"""
used = sum(p.stat().st_size for p in Path(MEDIA_ROOT).rglob("*"))
free = shutil.disk_usage(MEDIA_ROOT).free
quota = env.int("MEDIA_FILES_DISK_QUOTA", default=0)
disk_free = shutil.disk_usage(MEDIA_ROOT).free
free = min(disk_free, quota * 1024 * 1024 - used) if quota else disk_free
return used, free


Expand Down

0 comments on commit 693e387

Please sign in to comment.