浏览代码

fix repeated errors when server has only readonly access

Luke Pulverenti 9 年之前
父节点
当前提交
98020809c8
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs

+ 8 - 1
MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs

@@ -532,9 +532,16 @@ namespace MediaBrowser.Server.Implementations.IO
                 return false;
             }
 
+            // In order to determine if the file is being written to, we have to request write access
+            // But if the server only has readonly access, this is going to cause this entire algorithm to fail
+            // So we'll take a best guess about our access level
+            var requestedFileAccess = ConfigurationManager.Configuration.SaveLocalMeta
+                ? FileAccess.ReadWrite
+                : FileAccess.Read;
+
             try
             {
-                using (_fileSystem.GetFileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
+                using (_fileSystem.GetFileStream(path, FileMode.Open, requestedFileAccess, FileShare.ReadWrite))
                 {
                     if (_updateTimer != null)
                     {