If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

simple-storage should have 'clear' method

RESOLVED WORKSFORME

Status

Add-on SDK
General
P3
normal
RESOLVED WORKSFORME
4 years ago
4 years ago

People

(Reporter: Gregg Lind (Fx Strategy and Insights - Shield - Heartbeat ), Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

It's hard to clean out require('simple-storage').storage , which fronts `manager.root`.  

While we're at it, it would be nice to expose the 'toJSON' aspect of it... already, simpleStore checks for type.
P3, but patches welcome. :)
Priority: -- → P3
Whiteboard: [good first bug]
i started work on this, and realized the .storage property is totally accessible to addon code, can be enumerated, can be JSONified, and can even be set to anything. in short, this works:

> let ss = require('simple-storage');
> ss.storage.blah = 123;
> console.log(JSON.stringify(ss.storage));
> ss.storage = {};

that last line basically does what this bug is asking for, or am i misunderstanding something?

maybe by clear you mean to actually delete the stored json file?
Flags: needinfo?(glind)
Tomislav, 

If that all works (and tests show it!) then I am completely satisfied.  Make sure to try it with more complex types than `int` though!  

I did not mean that it should have to delete the stored on-disk file.
Flags: needinfo?(glind)
hey Gregg,

i went through existing tests for simple-storage, and they do all sorts of things to `.storage`, including stuff like this.

ok, i'm gonna close the bug with "works for me", and if someone disagrees, they can reopen it..
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → WORKSFORME
Whiteboard: [good first bug]
You need to log in before you can comment on or make changes to this bug.