sandstorm-io / collections-app

Sandstorm app for aggregating grains into a group
MIT License
25 stars 10 forks source link

reverse collection ID storage to grainID #10

Closed Xqua closed 8 years ago

Xqua commented 8 years ago

Hi,

I've been looking here https://github.com/sandstorm-io/collections-app/blob/master/src/identity_map.rs to find how the grains are stored

I gathered that the ID of the grain is truncated somehow and hashed with percent encode. Then this is stored under CollectionGrainID/sandbox/identities/ as symlinks.

I'm looking for the reverse function, aka going from the stored ID to the grain ID. Idealy, in python, perl, bash, or else.

anyone could help with this ?

PS: basically, I'm trying to find the grains associated with a collection on the server side, to Rsync those database and back them up automatically.

dwrensha commented 8 years ago

I've been looking here https://github.com/sandstorm-io/collections-app/blob/master/src/identity_map.rs to find how the grains are stored

That code saves Identity capabilities, so that the collection can fetch profile information and send notifications.

The code that saves the grain (UiView) capabilities is in server.rs.

I'm looking for the reverse function, aka going from the stored ID to the grain ID

The collection does not have the grain IDs and in fact would not be able to retrieve them event if it wanted to.

One way to see which grains are referenced in a collection might be to look at the ApiTokens table in the Mongo database, through sandstorm mongo. Look for the grainId field on the tokens with owner.grain.grainId equal to the collection's grain ID.

Xqua commented 8 years ago

Yes ! This worked ! Thanks !

For info, look for the "owner" tag in the apiToken DB, if it's a grain, and the grain is a collection you can bind them.