Repository navigation
Say how much Unbent has stored from the files themselves, not Chrome's count of them - #490
Merged
Merged
Conversation
…s count of them. Settings → Offline told a desktop install that "Unbent is using 3.98 GB" when the site held about 34 MB on disk. The figure was `navigator.storage.estimate()`, and Chrome put 4,245 MB under its `fileSystem` part while the files in the origin-private file system (the library, its search index, SQLite's scratch directories) came to 31 MB. The counter Chrome keeps for that file system read minus 82 MB. The caches and IndexedDB parts of the estimate were right. `storedBytes` (`store/usage.ts`) takes the estimate, swaps its `fileSystem` part for the sizes of the files actually there, and keeps the rest. Where the browser gives no parts (Firefox, Safari), or a file cannot be sized because SQLite holds it at that moment, it says the estimate as before, rather than a total that leaves the library out. Only the sentence changes. Whether a kept notebook fits, or a file can wait to upload, is still judged against the browser's own estimate, because that is the figure the browser holds the site to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Offline. The walk that sizes the stored files was awaited before the other figures on the page, and runs again whenever the outbox moves. With a notebook kept, that is thousands of files sized one after another, and the waiting uploads and the persistence line waited behind it each time. A slow walk could also land after a newer one and put back an older figure. The walk now runs beside the other figures, and only the newest one's answer is used. A walk that meets a file SQLite holds open at that moment now answers null rather than the browser's estimate, and the page keeps the last figure it measured: falling back to the estimate there would flick the sentence back to the very miscount it exists to replace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…owser's allowance.
The sentence read "Unbent is using 57 MB of the 13.98 GB this device allows it" once the stored figure was measured. That allowance is the browser's quota, which Chrome reports as its own usage plus 10 GiB, so it still carried the gigabytes of the miscount. Worse, Keep offline checks a notebook against the browser's room, so the same panel could say 57 MB of 13.98 GB and then that the device was out of room.
It now says the room left as the browser judges it ("and this device has room for 9.88 GB more"), which is the same `free` a kept notebook is checked against, so the two lines can no longer disagree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`fileSystemBytes` was exported, but only `storedBytes` in the same module calls it, and an export reads as an API someone else relies on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment on `storedBytes` said Chrome's count could be wrong by gigabytes, but not how. The counter had gone below zero (minus 82 MB) and was reported wrapped round 2^32, plus the real files: 4,295 - 82 + 33 = 4,246 MB, which is exactly what DevTools showed. A Chrome restart kept it; deleting the counter file with Chrome closed made Chrome measure the folder again, at 31 MB. Written down so the next reader knows the measured figure is guarding against a counter that underflows, not one that drifts upward. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preview: https://unbent-pr-490.of2668.workers.devSign in with Continue on the dev instance: a preview cannot register Runs against the shared Worker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Settings → Offline told two desktop installs "Unbent is using 3.98 GB" when each held about 31 MB. The figure came from
navigator.storage.estimate(), and Chrome's count of the origin-private file system was wrong by about 4 GB.Why Chrome's figure was wrong
Chrome keeps a running counter of each site's file-system usage (
File System/<n>/t/.usagein the profile). On both machines it had gone negative (minus 82.4 MB on one, minus 51.6 MB on the other). The reported usage was that counter wrapped round 2^32, plus the real files: 4,295 - 82 + 33 = 4,246 MB, exactly what DevTools showed. A Chrome restart kept it. Deleting the counter file with Chrome closed made Chrome measure the folder again (30.9 MB), so no data was ever wrong.Reproduced since in a clean Chrome profile (stable and Dev): bytes written through a
FileSystemSyncAccessHandleare counted in memory but never saved to that counter, so after a restart Chrome has forgotten them, and deleting the files then subtracts bytes that were never added. Write 1 MiB through a sync handle, restart, delete it, restart: Chrome reports 4,095 MB. The same bytes written withcreateWritablestay exact. wa-sqlite writes every database file through sync handles, and the sign-out wipe deletes the library and search index, so any Chrome that has run Unbent across a restart and a sign-out can land here. That is what this change is for. It is Chromium issue 436552046 (assigned, with the same diagnosis and a repro), first seen as 401692415.What changes
storedBytes(store/usage.ts) takes the browser's estimate and swaps itsusageDetails.fileSystempart for the sizes of the files actually there. Only that part was wrong; the caches and IndexedDB figures matched. Where the browser reports no parts (Firefox, Safari) it says the estimate as before.freethat Keep offline checks a notebook against, so the two can't disagree.Checked
usage.test.ts: the swap (4,245 MB counted, 31 MB on disk), no parts reported, a file held open, no estimate at all.OfflineStorage.test.tsx: the sentence with a measured figure and with only the estimate.main.To reset an affected Chrome by hand: quit it, delete the negative
.usagefile underFile System/<n>/t/in the profile, and reopen.🤖 Generated with Claude Code