MozillaZine

Force firefox to update bookmarks.html file

Discussion about official Mozilla Firefox builds
AndyB39
 
Posts: 5
Joined: April 27th, 2008, 9:56 am

Post Posted April 27th, 2008, 10:04 am

Im a relative newbie to firefox (and these forums) so I really hope this question isn't common knowledge that could be answered elsewhere:)

Im writing an application that reads the bookmarks.html file and extracts the bookmarks. As far as I know Firefox updates this file on exit only. Is there a way to force Firefox to update this file at any time while its running such as a key combination etc?

This needs to be a method that doesn't involve installing an extension.

Many thanks...

trolly
Moderator

User avatar
 
Posts: 39879
Joined: August 22nd, 2005, 7:25 am

Post Posted April 27th, 2008, 10:09 am

Not that i know.
But be aware that FF3 will use a sqlite database instead of the HTML file.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.

the-edmeister

User avatar
 
Posts: 31974
Joined: February 25th, 2003, 12:51 am
Location: Chicago, IL, USA

Post Posted April 27th, 2008, 3:21 pm

Andy wrote:As far as I know Firefox updates this file on exit only.
I haven't seen any documentation regarding that to direct you to, but based upon my observations while 'pushing the limits' in Firefox - no, bookmarks.html is always up-to-date when adding or deleting a bookmark. I share a 'remote' bookmarks.html file among a few Profiles that I run simultaneously, when I add a new bookmark in one Profile it appears in the other Profiles at the same instance. I have seen that happen repeatedly when running 2 or 3 Profiles that were in tiled windows with the bookmarks Sidebar open.

As trolly mentioned, Firefox 3 uses an all new SQLite database for bookmarks and history called places.sqlite. Now, that file isn't updated until Firefox is closed, from what I have observed in running vs. closed Profile files. It looks like the 'temp' data is held in places.sqlite-journal and/or places.sqlite-stmtjrnl files until the "closing routine" is started and that data is written to places.sqlite when Firefox is closed.
A mind is a terrible thing to waste. Mine has wandered off and I'm out looking for it.

AndyB39
 
Posts: 5
Joined: April 27th, 2008, 9:56 am

Post Posted April 28th, 2008, 7:18 am

Thanks for that.

I wasn't aware of the bookmark file changing to sqlite so that was a welcome heads up:) Its my own stupid fault but it makes my task very difficult now though as Ive got solid code to trawl and extract (inc icons) from a bookmarks.html file and there are no similarities between how it is stored then and in FF3. C'est la vie!

Just as an aside it looks like places.sqlite gets locked when a new bookmark is added or a new url is visited but is free to be read before that. It would be nice (from my point of view) if it was locked, updated then released otherwise I'd have to ask my users to close down FF before importing. Not being part of or knowing much about the Firefox community what (who or where) would be the best person to talk to about this?

trolly
Moderator

User avatar
 
Posts: 39879
Joined: August 22nd, 2005, 7:25 am

Post Posted April 28th, 2008, 7:30 am

Over to "Builds" ...
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.

pal-moz
 
Posts: 5937
Joined: September 23rd, 2005, 5:40 pm
Location: Tokyo , Japan

Post Posted April 28th, 2008, 7:51 am

@AndyB39

about bookmarks.html(bookmarks.postplaces.html), see https://bugzilla.mozilla.org/show_bug.cgi?id=423082

dickvl

User avatar
 
Posts: 52285
Joined: July 18th, 2005, 3:25 am

Post Posted April 28th, 2008, 9:11 am

There is a pref that makes Firefox 3 create a file bookmarks.html on Exit: browser.bookmarks.autoExportHTML
I don't know if b5 already has it.

C@rb0n
 
Posts: 1426
Joined: February 19th, 2005, 11:22 am

Post Posted April 28th, 2008, 12:07 pm

dickvl wrote:There is a pref that makes Firefox 3 create a file bookmarks.html on Exit: browser.bookmarks.autoExportHTML
I don't know if b5 already has it.

You probably shouldn't do that if you have lots of bookmarks, as this can add significant browser shutdown delay.

the-edmeister

User avatar
 
Posts: 31974
Joined: February 25th, 2003, 12:51 am
Location: Chicago, IL, USA

Post Posted April 29th, 2008, 12:38 am

dickvl wrote:There is a pref that makes Firefox 3 create a file bookmarks.html on Exit: browser.bookmarks.autoExportHTML
I don't know if b5 already has it.
I am running the Minefield nightlies and I can't get that pref to work. It continues to save the backup as JSON.
A mind is a terrible thing to waste. Mine has wandered off and I'm out looking for it.

AndyB39
 
Posts: 5
Joined: April 27th, 2008, 9:56 am

Post Posted April 29th, 2008, 8:27 am

Ive just run the latest nightly and it creates a bookmarks.html file in the same directory as places.sqlite not the backup dirs.

As C@rb0n said though I don't want to FF to chug on large bookmark sets plus I can't update the config of FF on the fly for a user (theres no way to do it unless I change prefs.js when FF isnt running and the rfdid's are missing from the bookmarks file anyway). So no point using browser.bookmarks.autoExportHTML unfortunatly.

Decided to implement sqlite instead and go from there. It would be nice if FF didn't lock the places file from the first url/bookmark change though - I can understand it from a performance point of view I but I only need read only access..

SlimShady
 
Posts: 148
Joined: November 4th, 2004, 3:21 pm

Post Posted April 29th, 2008, 8:46 am

You could make an extension that exports the bookmarks.

Racer
 
Posts: 6108
Joined: November 18th, 2002, 11:07 am

Post Posted April 29th, 2008, 8:54 am

You have two good options:
1) Write an extension that exports the bookmarks whenever they are changed. This could export in whatever format you want - so you don't even need to parse bookmarks.html.
2) Write a program that uses the sqlite database tool to query the file. There are a number of example programs out there to start with.

I like #1 as it has almost no overhead and immediately updates whatever destination you desire.

dickvl

User avatar
 
Posts: 52285
Joined: July 18th, 2005, 3:25 am

Post Posted April 29th, 2008, 3:26 pm

The backups are still in JSON if you set the pref browser.bookmarks.autoExportHTML.
Only there will be a file bookmarks.html created in the main profile folder, just like Firefox 2 does.
That bookmarks.html file also has the 'Unfiled' bookmarks at the end, so you have them all.
I haven't yet tried to import such a file to see what happens with the currently unfiled bookmarks (merge or remove double or replace?).

a;skdjfajf;ak

User avatar
 
Posts: 17002
Joined: July 10th, 2004, 8:44 am

Post Posted April 29th, 2008, 3:31 pm

Also keep in mind that forcing a html backup, if you use 'tags' and maybe 'keywords' they are NOT backed up/saved when creating an html file.

the-edmeister

User avatar
 
Posts: 31974
Joined: February 25th, 2003, 12:51 am
Location: Chicago, IL, USA

Post Posted April 29th, 2008, 3:59 pm

dickvl wrote:Only there will be a file bookmarks.html created in the main profile folder, just like Firefox 2 does.
OK, now I see that the existing bookmarks.html file directly in the Profiles folder does get updated upon closing Minefield when that preference is set, I was expecting it to appear in the \bookmarkbackups\ folder in place of the JSON file.

Racer wrote:1) Write an extension that exports the bookmarks whenever they are changed. This could export in whatever format you want - so you don't even need to parse bookmarks.html.
BookmarkBackup for 1.5 and higher has code to do timed interval backups of bookmarks.html. I think the pref is bookmarkbackup.interval where the default value is 120 (seconds). That code isn't gonna help Andy with Firefox 3 and Places, directly, but it might give him some ideas.


Ed
A mind is a terrible thing to waste. Mine has wandered off and I'm out looking for it.

Return to Firefox Builds


Who is online

Users browsing this forum: No registered users and 2 guests