Tech Debt + Series Sort bugfix (#1192)
* Code cleanup. When copying files, if the target file already exists, append (1), (2), etc onto the file (this is enhancing existing implementation to allow multiple numbers) * Added a ton of null checks to UpdateSeriesMetadata and made the code work on the rare case (not really possible) that SeriesMetadata doesn't exist. * Updated Genre code to use strings to ensure a better, more fault tolerant update experience. * More cleanup on the codebase * Fixed a bug where Series SortName was getting emptied on file scan * Fixed a bad copy * Fixed unit tests
This commit is contained in:
parent
a00e8f121f
commit
19678383b2
17 changed files with 362 additions and 138 deletions
|
|
@ -557,6 +557,24 @@ namespace API.Tests.Services
|
|||
Assert.Equal(2, ds.GetFiles("/manga/output/").Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CopyFilesToDirectory_ShouldAppendWhenTargetFileExists()
|
||||
{
|
||||
const string testDirectory = "/manga/";
|
||||
var fileSystem = new MockFileSystem();
|
||||
fileSystem.AddFile($"{testDirectory}file.zip", new MockFileData(""));
|
||||
fileSystem.AddFile($"/manga/output/file (1).zip", new MockFileData(""));
|
||||
fileSystem.AddFile($"/manga/output/file (2).zip", new MockFileData(""));
|
||||
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
ds.CopyFilesToDirectory(new []{$"{testDirectory}file.zip"}, "/manga/output/");
|
||||
ds.CopyFilesToDirectory(new []{$"{testDirectory}file.zip"}, "/manga/output/");
|
||||
var outputFiles = ds.GetFiles("/manga/output/").Select(API.Parser.Parser.NormalizePath).ToList();
|
||||
Assert.Equal(4, outputFiles.Count()); // we have 2 already there and 2 copies
|
||||
// For some reason, this has C:/ on directory even though everything is emulated
|
||||
Assert.True(outputFiles.Contains(API.Parser.Parser.NormalizePath("/manga/output/file (3).zip")) || outputFiles.Contains(API.Parser.Parser.NormalizePath("C:/manga/output/file (3).zip")));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListDirectory
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue