Question

I want to use linux quota in rails app to limit user's space usage on disk. But my current implementation will save users' attachments as they are owned by which one who start up rails app. Do I need to create every users on linux server and assign them a disk quota?

So, is there any rails plugin/gems allow me to do this? And what is github solution? They did not only limit the size of attachments but also user's git repositories. Thanks.

Was it helpful?

Solution

It's better to limit user's disk space usage on application level, without the use of OS-level tools.

As a simple example, add disk_quota and current_disk_usage fields to user model, update current_disk_usage after each successful file upload. Before each file upload, throw an exception if uploaded file size + current_disk_usage > disk_quota.

This is much more versatile and cross-platform approach. This way you are not limiting yourself to using Linux OS, can store your files and your application server(s) on different machines, can store your files on Amazon S3, etc. Plus, it's much more maintainable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top