Pausing point. Refactored the code to use a better comparison method for images and to use a temp directory for the download.
Optimized code for checking similarity for Person Cover image against known placeholders from AniList. There are still bugs around memory-mapped sections being opened when trying to manipulate files.
This commit is contained in:
parent
1d9084fe49
commit
32c035b5c8
4 changed files with 541 additions and 111 deletions
|
|
@ -69,6 +69,7 @@ public interface IDirectoryService
|
|||
IEnumerable<string> GetFiles(string path, string fileNameRegex = "", SearchOption searchOption = SearchOption.TopDirectoryOnly);
|
||||
bool ExistOrCreate(string directoryPath);
|
||||
void DeleteFiles(IEnumerable<string> files);
|
||||
void CopyFile(string sourcePath, string destinationPath, bool overwrite = true);
|
||||
void RemoveNonImages(string directoryName);
|
||||
void Flatten(string directoryName);
|
||||
Task<bool> CheckWriteAccess(string directoryName);
|
||||
|
|
@ -937,6 +938,27 @@ public class DirectoryService : IDirectoryService
|
|||
}
|
||||
}
|
||||
|
||||
public void CopyFile(string sourcePath, string destinationPath, bool overwrite = true)
|
||||
{
|
||||
if (!File.Exists(sourcePath))
|
||||
{
|
||||
throw new FileNotFoundException("Source file not found", sourcePath);
|
||||
}
|
||||
|
||||
var destinationDirectory = Path.GetDirectoryName(destinationPath);
|
||||
if (string.IsNullOrEmpty(destinationDirectory))
|
||||
{
|
||||
throw new ArgumentException("Destination path does not contain a directory", nameof(destinationPath));
|
||||
}
|
||||
|
||||
if (!Directory.Exists(destinationDirectory))
|
||||
{
|
||||
FileSystem.Directory.CreateDirectory(destinationDirectory);
|
||||
}
|
||||
|
||||
FileSystem.File.Copy(sourcePath, destinationPath, overwrite);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the human-readable file size for an arbitrary, 64-bit file size
|
||||
/// <remarks>The default format is "0.## XB", e.g. "4.2 KB" or "1.43 GB"</remarks>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue