9001 / copyparty

Portable file server with accelerated resumable uploads, dedup, WebDAV, FTP, TFTP, zeroconf, media indexer, thumbnails++ all in one file, no deps
MIT License
571 stars 34 forks source link

Per volume size/upload limit. #40

Closed Gremious closed 1 year ago

Gremious commented 1 year ago

is your feature request related to a problem? Please describe.

I want to share my copyparty instance with my friends so that they can use it for cloud storage/sharing, but I want to set e.g. a 1 TB upload limit for the volume I give to them.

Describe the idea / solution you'd like

I think the easier solution is definitely just a volflag like maxup/maxsize: 1tb which would just check the folder/volume size on upload, and if it's over the limit, deny the upload, no matter the IP.

Then you can simply set up a "user folder", and all works well.

Describe any alternatives you've considered

I suppose I can do maxb=1tb,9999999999... but that feels very hacky.

It is also different from checking volume size, since maxb is per ip and you can just use your phone or a vpn or something, not as hard of a limit, that's better at deterring random short-term users from messing around.

Also, maybe good idea to have a 50gb folder limit on like, a "shared"/"public" volume used by many random users. Also makes it possible to limit a volume used by two users, e.g. for a friend and their partner, where IP blocking won't work.

I've also consider per-user tracking, but:

  1. It would be far more annoying to do because you'd have to keep track of how much the user has uploaded/deleted somewhere (what if an upload breaks or the server internet cuts off?)
  2. It would not work for anon users e.g. friends-of-friends, where I provide a "shared" folder that has short-lived files so they can use it to go over e.g. Discord upload limits.

Additional context This app has so many features.... It is also the best one I've found, and I really searched...good job !!

9001 commented 1 year ago

Absolutely, this will be useful in a lot of scenarios. Added!

There's two new volflags; vmaxb specifies max total size of a volume, and vmaxn for max total number of files. Both take an optional SI suffix, so vmaxb=1t would be max 1024 GiB.

Unless I forgot something, it should also catch files that are mid-upload -- so if someone starts uploading a file that consumes most of the free space, it should stop additional uploads at the hashing stage (before the actual uploads begin). And looks like all this has surprisingly little performance impact too :+1:

You can grab a beta here if you'd like: https://ocv.me/copyparty-sfx.py

Thanks for the idea and for using copyparty :>