I wasn't able to fix the locking of the files, but I reordered the scanner to first perform the metadata download then try and generate cover images.
This commit is contained in:
parent
dab3377ded
commit
acdf187fa0
4 changed files with 45 additions and 10 deletions
|
|
@ -1112,4 +1112,23 @@ public class DirectoryService : IDirectoryService
|
|||
FlattenDirectory(root, subDirectory, ref directoryIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the file is locked or not existing
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsFileLocked(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(filePath)) return false;
|
||||
using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None);
|
||||
return false; // If this works, the file is not locked
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return true; // File is locked by another process
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue