瀏覽代碼

create notion of locked path

Luke Pulverenti 9 年之前
父節點
當前提交
10d4ad98d9

+ 7 - 0
MediaBrowser.Controller/Library/ILibraryMonitor.cs

@@ -32,5 +32,12 @@ namespace MediaBrowser.Controller.Library
         /// </summary>
         /// </summary>
         /// <param name="path">The path.</param>
         /// <param name="path">The path.</param>
         void ReportFileSystemChanged(string path);
         void ReportFileSystemChanged(string path);
+
+        /// <summary>
+        /// Determines whether [is path locked] [the specified path].
+        /// </summary>
+        /// <param name="path">The path.</param>
+        /// <returns><c>true</c> if [is path locked] [the specified path]; otherwise, <c>false</c>.</returns>
+        bool IsPathLocked(string path);
     }
     }
 }
 }

+ 7 - 0
MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs

@@ -64,6 +64,13 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
                 FileSize = new FileInfo(path).Length
                 FileSize = new FileInfo(path).Length
             };
             };
 
 
+            if (_libraryMonitor.IsPathLocked(path))
+            {
+                result.Status = FileSortingStatus.Failure;
+                result.StatusMessage = "Path is locked by other processes. Please try again later.";
+                return result;
+            }
+
             var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
             var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
             var resolver = new Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger());
             var resolver = new Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger());
 
 

+ 6 - 0
MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs

@@ -78,6 +78,12 @@ namespace MediaBrowser.Server.Implementations.IO
             TemporarilyIgnore(path);
             TemporarilyIgnore(path);
         }
         }
 
 
+        public bool IsPathLocked(string path)
+        {
+            var lockedPaths = _tempIgnoredPaths.Keys.ToList();
+            return lockedPaths.Any(i => string.Equals(i, path, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(i, path));
+        }
+
         public async void ReportFileSystemChangeComplete(string path, bool refreshPath)
         public async void ReportFileSystemChangeComplete(string path, bool refreshPath)
         {
         {
             if (string.IsNullOrEmpty(path))
             if (string.IsNullOrEmpty(path))