Archivist

Archivist

7.2k Downloads

DeleteAll with store type breaks Archivist for rest of session

Meorawr opened this issue ยท 0 comments

commented

self.sv[storeType] = nil

The current implementation of the Archivist:DeleteAll(storeType) function nils out the named store table in self.sv when a store type is explicitly passed. This leads to the rest of Archivist breaking if you then call other functions for the store type that was just deleted.

If called without an explicit store type the self.sv entries for each store type aren't nilled out and are instead replaced with empty tables, leaving Archivist functioning fine when other functions are called.

Very basic test case:

Archivist:Initialize({});
print(Archivist.sv.ReadOnly);
Archivist:DeleteAll("ReadOnly");
print(Archivist.sv.ReadOnly);
Archivist:Create("ReadOnly", "TestStore", ":)");  -- Error! :(
print(Archivist.sv.ReadOnly.TestStore);

This will throw the following error once it calls the Create function:

4x SecretProject\Libs\Archivist\Archivist.lua:200: attempt to index field '?' (a nil value)
[string "@SecretProject\Libs\Archivist\Archivist.lua"]:200: in function `Create'

Compared to the alternative of not passing a store name, no error occurs:

Archivist:Initialize({});
print(Archivist.sv.ReadOnly);
Archivist:DeleteAll();
print(Archivist.sv.ReadOnly);
Archivist:Create("ReadOnly", "TestStore", ":)");
print(Archivist.sv.ReadOnly.TestStore);