Question about .localstorage file sizes

66 views
Skip to first unread message

Sean Cassell

unread,
Aug 24, 2015, 11:54:53 AM8/24/15
to Chromium-extensions
Hello;

I use an extension that adds functionality to a website I visit. One of the features allows me to make notes about individual users for future reference. This question is not about that particular extension, but I am going to use it as an example to illustrate my question.



Some background:
I like to periodically backup the .localstorage and the .localstorage-journal files for that extension so that I don't lose my notes if my HDD fails. I have noticed that on my computer, the file sizes for that extension never seem to change. The .localstorage file is always 2.04 MB (2,146,304 bytes) and the .localstorage-journal file is always 16.0 KB (16,384 bytes). I add notes frequently, so I would expect the file sizes to increase over time.


My question:
When an extension is installed that saves information to a .localstorage file, does Chrome create an initial .localstorage file of a pre-determined size? Sort of like how when you create a virtual machine in a program like VirtualBox or VMWare, you can choose to have the virtual HDD file take up a pre-determined amount of space when the file is created, and data is added to the file without increasing the virtual HDD file size.


From what I can tell, I am not losing any previously-saved notes when I add a new one. I posted this question because I'm trying to figure out whether this is normal behaviour for all extensions or if this is something particular to the extension I am using. If this is expected/normal behaviour for .localstorage file usage, will the file size increase at some point? I have read that there is a size limit of 5MB for local storage files, so if the file size is allocated in advance, it seems odd that it would be less than half of the maximum size.



Thank you in advance for any answers.

Antony Sargent

unread,
Aug 26, 2015, 7:38:37 PM8/26/15
to Sean Cassell, Chromium-extensions
Those .localstorage/.localstorage-journal files are SQLite databases, and it's likely both that some amount of extra space is pre-allocated when the file needs to grow with new entries and that space freed up by deleting entries does not cause the file size to shrink immediately (but rather is reserved for future new entries). 

If you aren't already aware of it, you can use the command line interface for sqlite to look at the data in these files: https://www.sqlite.org/cli.html (https://www.sqlite.org/download.html to get a binary for your system)



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/48aebb58-839b-4c9b-ad41-59e126ba4814%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Abhi S

unread,
Aug 27, 2015, 2:53:19 AM8/27/15
to Antony Sargent, Sean Cassell, Chromium-extensions
Antony, Thanks for the inputs. 

Given this context of persisting the "local storage" data which is not Synced using Google Chrome Sync how would/ could we do the following? 

- Migrate/ Copy/ Backup/ Restore these listed things to other secondary PCs and/ or to new PCs: 

  • Extensions 
    - Extension Configs/ Settings + Extension Local Stored Data (Very important)
    • (Especially, in extensions like Session Buddy I have stored stuff for few years now)
Bonus: How could we do this for Extensions which are no longer published in the Chrome Store but still work on existing machines? 

Please do guide as we've been storing important local data in these extensions, but no way to carry forward/ migrate them to our other PCs or new PCs?

Antony Sargent

unread,
Aug 27, 2015, 11:52:15 AM8/27/15
to Abhi S, Sean Cassell, Chromium-extensions
Unfortunately I don't think there's any officially supported way to do this.

It's possible that things would happen to work ok if you shut down chrome and copied the relevant .localstorage/.localstorage-journal files from your profile directory, but I don't think we can provide any guarantees about this, or that it wouldn't break in the future (eg we might one day switch from using sqlite to leveldb or something else, and/or start using different file names). 

 
Reply all
Reply to author
Forward
0 new messages