mirror of
https://github.com/Radarr/Radarr
synced 2025-02-25 07:32:56 +00:00
Fixed: FolderWritable check for CIFS shares mounted in Unix
This reverts commit 8c892a732e
.
This commit is contained in:
parent
f90211b0d3
commit
96384521c5
2 changed files with 21 additions and 2 deletions
|
@ -10,6 +10,16 @@ namespace NzbDrone.Common.Test.DiskTests
|
||||||
public abstract class DiskProviderFixtureBase<TSubject> : TestBase<TSubject>
|
public abstract class DiskProviderFixtureBase<TSubject> : TestBase<TSubject>
|
||||||
where TSubject : class, IDiskProvider
|
where TSubject : class, IDiskProvider
|
||||||
{
|
{
|
||||||
|
[Test]
|
||||||
|
public void writealltext_should_truncate_existing()
|
||||||
|
{
|
||||||
|
var file = GetTempFilePath();
|
||||||
|
|
||||||
|
Subject.WriteAllText(file, "A pretty long string");
|
||||||
|
Subject.WriteAllText(file, "A short string");
|
||||||
|
Subject.ReadAllText(file).Should().Be("A short string");
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Retry(5)]
|
[Retry(5)]
|
||||||
public void directory_exist_should_be_able_to_find_existing_folder()
|
public void directory_exist_should_be_able_to_find_existing_folder()
|
||||||
|
|
|
@ -131,7 +131,7 @@ public bool FolderWritable(string path)
|
||||||
{
|
{
|
||||||
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 @@ public void WriteAllText(string filename, string contents)
|
||||||
{
|
{
|
||||||
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.Create, 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…
Reference in a new issue