Browse Source

fixes #168 - Resumable & Favorite items showing up for all users.

Luke Pulverenti 12 years ago
parent
commit
6ddb9958c4

+ 13 - 2
MediaBrowser.Server.Implementations/Sqlite/SQLiteUserDataRepository.cs

@@ -147,7 +147,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
                 var newValue = Task.FromResult(userData);
 
                 // Once it succeeds, put it into the dictionary to make it available to everyone else
-                _userData.AddOrUpdate(key, newValue, delegate { return newValue; });
+                _userData.AddOrUpdate(GetInternalKey(userId, key), newValue, delegate { return newValue; });
             }
             catch (Exception ex)
             {
@@ -157,6 +157,17 @@ namespace MediaBrowser.Server.Implementations.Sqlite
             }
         }
 
+        /// <summary>
+        /// Gets the internal key.
+        /// </summary>
+        /// <param name="userId">The user id.</param>
+        /// <param name="key">The key.</param>
+        /// <returns>System.String.</returns>
+        private string GetInternalKey(Guid userId, string key)
+        {
+            return userId + key;
+        }
+
         /// <summary>
         /// Persists the user data.
         /// </summary>
@@ -223,7 +234,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
                 throw new ArgumentNullException("key");
             }
             
-            return _userData.GetOrAdd(key, keyName => RetrieveUserData(userId, key));
+            return _userData.GetOrAdd(GetInternalKey(userId, key), keyName => RetrieveUserData(userId, key));
         }
 
         /// <summary>