Collect a number that could be used to enforce a (soft) quota, updating automatically as objects are received and removed.
git annex info --json --bytes --show 'annex sizes of repositories' cannot
be used for a quota because bad information could be put into the
git-annex branch. (Eg send objects to the server, then pull the git-annex
branch from the server to get its updates, and overwrite them.)
git annex info --json --bytes --show 'local annex size' is too slow
to query since it walks the object directory tree.
Also both of the above omit the size of keys w/o a stated size. A quota needs to include the actual file size of such keys.
And this should also handle partially transferred objects. It would be possible to count each chunk as it's received, and update the value stored on disk after each megabyte or gigabyte. (Make the update granularity tunable with a git config.)
This is complicated by concurrency. For example 2 processes can both drop the same key at the same time and both succeed, so if both update the number it would be wrong. Database.RepoSize already deals with much the same problems for live size changes.
Maybe another angle on this is that git-annex branch changes with incorrect information for the local repository should be automatically corrected.
Then the existing repository size tracking could be used for a quota (Ignoring keys w/o a stated size which could just be rejected from being received by a repository with a quota). Perhaps supplimented with the size of partially transferred objects.
Since calcBranchRepoSizes already sees all changes to location logs, it could just check if changes for the local repository are accurate. And journal a correction to the location log when they're not.
When the git-annex branch is updated locally, we know those changes are accurate, so it could skip the double checking them. That would make this have almost zero overhead.