diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index d4d2c5668..d2f9ec470 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -131,7 +131,7 @@ public bool FolderWritable(string path) { var testPath = Path.Combine(path, "radarr_write_test.txt"); var testContent = string.Format("This file was created to verify if '{0}' is writable. It should've been automatically deleted. Feel free to delete it.", path); - File.WriteAllText(testPath, testContent); + WriteAllText(testPath, testContent); File.Delete(testPath); return true; } @@ -300,7 +300,16 @@ public void WriteAllText(string filename, string contents) { Ensure.That(filename, () => filename).IsValidPath(); RemoveReadOnly(filename); - File.WriteAllText(filename, contents); + + // File.WriteAllText is broken on net core when writing to some CIFS mounts + // This workaround from https://github.com/dotnet/runtime/issues/42790#issuecomment-700362617 + using (var fs = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) + { + using (var writer = new StreamWriter(fs)) + { + writer.Write(contents); + } + } } public void FolderSetLastWriteTime(string path, DateTime dateTime)