Closed Bug 1883514 Opened 2 months ago Closed 1 month ago

Add an async version of nsIPrefService.savePrefFile that takes a path for a new file on disk

Categories

(Core :: Preferences: Backend, task)

task

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: mconley, Assigned: mconley)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fidefe-device-migration])

Attachments

(1 file)

nsIPrefService.savePrefFile writes the prefs state to a local file: https://searchfox.org/mozilla-central/rev/202c48686136360a23b73a49b611a19e64f3e1b8/modules/libpref/nsIPrefService.idl#65-79

If passed null, this writes it to the default prefs.js file - however, callers can supply it with an nsIFile pointing at a new file to write to.

It looks like if you pass it an nsIFile, we only do blocking writes: https://searchfox.org/mozilla-central/rev/202c48686136360a23b73a49b611a19e64f3e1b8/modules/libpref/Preferences.cpp#4397

The team working on profile backup would like to make it possible to flush prefs to a backup folder on disk without blocking the main thread, and either to return a Promise to indicate when it's done (or to fire an observer notification passing the nsIFile path as either topic or data. I'm open to either, or alternatives).

Instead of modifying the existing savePrefFile method to accommodate that, I suspect it'll be easier to add an nsIPrefService.savePrefFileAsync with this behaviour, since savePrefFile is already fairly nuanced on when it chooses to write synchronously, and when it does not. I think we can probably simplify it a bit by having this new method not accept null, and only accept a path that isn't the default prefs.js path.

Component: Profiles → Preferences
Product: Firefox → Toolkit
Assignee: nobody → mconley
Status: NEW → ASSIGNED
Component: Preferences → Preferences: Backend
Product: Toolkit → Core
Blocks: 1885939
Pushed by smolnar@mozilla.com:
https://hg.mozilla.org/mozilla-central/rev/6f4cc4b08427
Add nsIPrefService.backupPrefFile to asynchronously write prefs to a backup file. r=KrisWright
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: