Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing objects through state service sometimes results in non-intuitive behavior #233

Open
lewisl9029 opened this issue Aug 21, 2015 · 1 comment

Comments

@lewisl9029
Copy link
Owner

This is because the abstraction between the in-memory baobab tree and the remotestorage module is a leaky one: The baobab tree is hierarchical, while we're using remotestorage as a flat key-value store (probably against best practices, but this was necessary to enable encryption of storage keys in addition to values).

If we save using

state.save(state.cloud.notifications, [notificationId, 'notificationInfo'], {})

We cannot remove it by calling remove on the parent key using

state.remove(state.cloud.notifications, [notificationId])

because there is no such key in remotestorage, as only the path storage.getStorageKey(state.cloud.notifications, [notificationId, 'notificationInfo']) exists, so the removal will fail.

Instead we must call

state.remove(state.cloud.notifications, [notificationId, 'notificationInfo'])

This could become more problematic later on as we make more use of state.remove and when we need the ability to remove entire subpaths at once. Consider switching to non-encrypted, hierarchical storage keys that map 1:1 with the underlying baobab tree.

@lewisl9029 lewisl9029 changed the title Removing objects through state service sometimes exhibits non-intuitive behaviors Removing objects through state service sometimes results in non-intuitive behavior Aug 21, 2015
@lewisl9029
Copy link
Owner Author

Actually they can't map 1:1 yet unless we refactor state.save to break down objects into individual properties and save each separately.

This would make state service more robust but increase storage requirements. Might possibly reduce the effectiveness of the crypto since some values can be very short and might make brute forcing easier if they were split up into separate properties (possibly not due to the length of the IV)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant