Ver Fonte

don't keep calling Path.combine for critic reviews

Luke Pulverenti há 12 anos atrás
pai
commit
9bb1588afd

+ 11 - 19
MediaBrowser.Server.Implementations/Sqlite/SQLiteItemRepository.cs

@@ -67,6 +67,8 @@ namespace MediaBrowser.Server.Implementations.Sqlite
         /// </summary>
         /// </summary>
         private SQLiteCommand _saveChildrenCommand;
         private SQLiteCommand _saveChildrenCommand;
 
 
+        private string _criticReviewsPath;
+
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
         /// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
         /// </summary>
         /// </summary>
@@ -88,6 +90,8 @@ namespace MediaBrowser.Server.Implementations.Sqlite
 
 
             _appPaths = appPaths;
             _appPaths = appPaths;
             _jsonSerializer = jsonSerializer;
             _jsonSerializer = jsonSerializer;
+
+            _criticReviewsPath = Path.Combine(_appPaths.DataPath, "critic-reviews");
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -468,23 +472,6 @@ namespace MediaBrowser.Server.Implementations.Sqlite
             }
             }
         }
         }
 
 
-        /// <summary>
-        /// Gets the critic reviews path.
-        /// </summary>
-        /// <param name="create">if set to <c>true</c> [create].</param>
-        /// <returns>System.String.</returns>
-        private string GetCriticReviewsPath(bool create)
-        {
-            var path = Path.Combine(_appPaths.DataPath, "critic-reviews");
-
-            if (create && !Directory.Exists(path))
-            {
-                Directory.CreateDirectory(path);
-            }
-
-            return path;
-        }
-
         /// <summary>
         /// <summary>
         /// Gets the critic reviews.
         /// Gets the critic reviews.
         /// </summary>
         /// </summary>
@@ -497,7 +484,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
 
 
                 try
                 try
                 {
                 {
-                    var path = Path.Combine(GetCriticReviewsPath(false), itemId + ".json");
+                    var path = Path.Combine(_criticReviewsPath, itemId + ".json");
 
 
                     return _jsonSerializer.DeserializeFromFile<List<ItemReview>>(path);
                     return _jsonSerializer.DeserializeFromFile<List<ItemReview>>(path);
                 }
                 }
@@ -523,7 +510,12 @@ namespace MediaBrowser.Server.Implementations.Sqlite
         {
         {
             return Task.Run(() =>
             return Task.Run(() =>
             {
             {
-                var path = Path.Combine(GetCriticReviewsPath(true), itemId + ".json");
+                if (!Directory.Exists(_criticReviewsPath))
+                {
+                    Directory.CreateDirectory(_criticReviewsPath);
+                }
+
+                var path = Path.Combine(_criticReviewsPath, itemId + ".json");
 
 
                 _jsonSerializer.SerializeToFile(criticReviews.ToList(), path);
                 _jsonSerializer.SerializeToFile(criticReviews.ToList(), path);
             });
             });