mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 21:12:43 +02:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user