@@ -274,7 +274,32 @@ func (r *Store) GetEntryByID(id string) (*shared.Entry, error) {
274274func (r * Store ) GetUserEntries (userIdentifier string ) (map [string ]shared.Entry , error ) {
275275 logrus .Debugf ("Getting all entries for user %s" , userIdentifier )
276276 entries := map [string ]shared.Entry {}
277+ key := userToEntriesPrefix + userIdentifier
278+ result := r .c .SMembers (key )
279+ if result .Err () != nil {
280+ msg := fmt .Sprintf ("Could not fetch set of entries for user '%s': %v" , userIdentifier , result .Err ())
281+ logrus .Errorf (msg )
282+ return nil , errors .Wrap (result .Err (), msg )
283+ }
284+ for _ , v := range result .Val () {
285+ logrus .Debugf ("got entry: %s" , v )
286+ entry , err := r .GetEntryByID (string (v ))
287+ if err != nil {
288+ msg := fmt .Sprintf ("Could not get entry '%s': %s" , v , err )
289+ logrus .Warn (msg )
290+ } else {
291+ entries [string (v )] = * entry
292+ }
293+ }
294+ logrus .Debugf ("all out of entries" )
295+ return entries , nil
296+ }
277297
298+ // GetAllUserEntries returns all entries for all users, in the
299+ // form of a map of path->shared.Entry
300+ func (r * Store ) GetAllUserEntries () (map [string ]shared.Entry , error ) {
301+ logrus .Debugf ("Getting all entries for all users" )
302+ entries := map [string ]shared.Entry {}
278303 users := r .c .Keys (userToEntriesPrefix + "*" )
279304 for _ , v := range users .Val () {
280305 logrus .Debugf ("got userEntry: %s" , v )
@@ -285,7 +310,7 @@ func (r *Store) GetUserEntries(userIdentifier string) (map[string]shared.Entry,
285310 // result := r.c.Keys(entryPathPrefix + user)
286311
287312 if result .Err () != nil {
288- msg := fmt .Sprintf ("Could not fetch set of entries for user '%s': %v" , userIdentifier , result .Err ())
313+ msg := fmt .Sprintf ("Could not fetch set of entries for user '%s': %v" , key , result .Err ())
289314 logrus .Errorf (msg )
290315 return nil , errors .Wrap (result .Err (), msg )
291316 }
0 commit comments