Fixed: FolderWritable check for CIFS shares mounted in Unix

See https://github.com/dotnet/runtime/issues/42790

Implemented workaround in https://github.com/dotnet/runtime/issues/42790#issuecomment-700362617

[common]
pull/5604/head
ta264 4 years ago
parent 226ee34fec
commit a71874db8d

@ -131,7 +131,7 @@ namespace NzbDrone.Common.Disk
{ {
var testPath = Path.Combine(path, "radarr_write_test.txt"); 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); 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); File.Delete(testPath);
return true; return true;
} }
@ -300,7 +300,16 @@ namespace NzbDrone.Common.Disk
{ {
Ensure.That(filename, () => filename).IsValidPath(); Ensure.That(filename, () => filename).IsValidPath();
RemoveReadOnly(filename); 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) public void FolderSetLastWriteTime(string path, DateTime dateTime)

Loading…
Cancel
Save