Skip import when when folder is in use

Fixed: Skip post-processing when folder is in use or series path does
not exist on disk
This commit is contained in:
Mark McDowall
2012-10-20 01:01:47 -07:00
parent 5014745f88
commit 5cc2810f77
4 changed files with 84 additions and 8 deletions

View File

@@ -232,5 +232,41 @@ namespace NzbDrone.Common
{
Directory.SetLastWriteTimeUtc(path, dateTime);
}
public virtual bool IsFolderLocked(string path)
{
var files = GetFileInfos(path, "*.*", SearchOption.AllDirectories);
foreach(var fileInfo in files)
{
if (IsFileLocked(fileInfo))
return true;
}
return false;
}
public virtual bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
}
catch (IOException)
{
return true;
}
finally
{
if (stream != null)
stream.Close();
}
//file is not locked
return false;
}
}
}