feat: support `max_upload_dir_size` config
Description
This Pull Request adds a feature to limit the uploads if the ./uploads dir is full. The size of ./uploads dir can be set by the config key max_upload_dir_size under the server config.
[server]
max_upload_dir_size = "100G"
Motivation and Context
This is required to restrict the number / size of uploads that can be made to the server when hosted publicly. This fixes #282
How Has This Been Tested?
Changelog Entry
- Add a check for the max size of uploads directory
Types of Changes
- [x] New feature (non-breaking change which adds functionality)
Checklist:
Let's get this over the finish line soon if possible :)
Ping :)
@Narayanbhat166 can you have a look and make the requested changes?
Codecov Report
Attention: Patch coverage is 6.66667% with 28 lines in your changes missing coverage. Please review.
Project coverage is 80.51%. Comparing base (
1d5a9c6) to head (aad5f77). Report is 29 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/util.rs | 0.00% | 17 Missing :warning: |
| src/paste.rs | 15.38% | 11 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #335 +/- ##
==========================================
- Coverage 83.27% 80.51% -2.76%
==========================================
Files 11 11
Lines 1214 1273 +59
==========================================
+ Hits 1011 1025 +14
- Misses 203 248 +45
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@orhun I was just wondering what kind of perf impact this has. Isn't this similar to the duplicates=false issue? Every time there is an upload, all files have to be touched. Yes, getting the size of all files is probably a lot faster than calculating the hash for each file, but still. Patterns like this make me nervous, coming from a perf background.
Yeah, probably the performance will be degrade in a noticeable way with this feature enabled.
I think we need to add benchmarks using hyperfine to get an idea about that. I did something similar for Zig in https://github.com/orhun/zig-http-benchmarks