I'm trying to write a special remote protocol in which it would be really helpful to have the exact size for a particular key. I was thinking of something like the special remote asking git-annex GETKEYINFO <key-id>
and git annex responds with some useful info (Something like a dictionary of useful values maybe?)
I considered doing something like git annex info ..
to figure this out but realized it's a bad idea(That'll be very brittle, plus it won't work well with chunked/encrypted remotes at all). Does git annex typically have this info available? It would even be helpful if it only gives responses in specific cases (eg: no encryption since it'll presumably be hard to keep track of that case)
git-annex examinekey --format='${bytesize}\n'
Or
git-annex examinekey --json
and use thebytesize
field.(You will probably want to use
--batch
to keep a single examinekey process running, for speed.)Note that not all keys have a known size. Usually keys without a known size were added with eg
git-anex addurl --fast
. Encrypted keys also won't have a size field.Also, when chunking is used with a special remote (without encryption), each chunk is a key, with its size field set to the total size of the original key. In that case there is a separate chunk size field, although the last chunk may be smaller than its chunk size field. If it would be useful, examinekey could have something added to it to indicate when a key is a chunk key, and show the chunk size.