Open ftreesmilo opened 3 years ago
Hello,
To get the current general quota usage, you could use StorageManager.estimate()
(MDN). There's also the Storage-Foundation-specific getRemainingCapacity()
, that tells you how much capacity is left in the current context.
I may have been using it wrong, or the current impl may have a bug... but getRemainingCapacity appeared to be giving me the capacity i requested, not remaining... also... I notice in the dev tools that this storage does not seem to hit the quotas listed there.. and is also not visible to inspect.
I would have expected to see 2 apis in Storage-Foundation. getRemainingCapacity() and getQuotaCapacity() something like that.
you'll see the situation that I ran into pretty quickly when needing to add more capacity...
I need 500 more megs... there's no api to request 500 MORE megs... What i have + 500 megs == what I need to request.
What to I currently have? How much of it am I using?
These apis seem lacking at the moment.
@fivedots I think I see what's happening...
If I don't write to any files, it doesn't consume any capacity.
If I setLength(>0) on the file, it doesn't consume any capacity. yes it does
If I write 1 byte to beginning of the file, it consumes 1 byte.
If I write 1 byte to the end of the file, it consumes the size of the file
bytes.
I'd like to see a few more apis to be able to see used capacity, and granted capacity.
@fivedots it would be really swell if you published a test suite to show usage. Feel free to plunder, link, or contribute: https://github.com/ftreesmilo/storage-foundation-tests
You mean I have to iterate all the files and sum their size?