Misc Bugfixes (#1015)

* Fixed some security issues in dev env

* When deleting folders in bookmark cleanup, delete empty folders correctly.

* When a new library is created and cards are added, cards can have a blank library name. Card library name code is reworked to be much lighter on memory.

* Added a config for github issues to disable blank issues.

* Skip any sort of directory iteration code if we haven't deleted any bookmarks.

* Fixed a bug where some style overrides were duplicating. Now logic is much more targetted, only applying to the correct tags.

* Applied sorting to the filtering apis.

* Reverted one of my changes for a better version Robbie did.
This commit is contained in:
Joseph Milazzo 2022-01-31 08:50:13 -08:00 committed by GitHub
parent c631395aae
commit c6d1311560
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 186 additions and 47 deletions

View file

@ -400,6 +400,78 @@ public class CleanupServiceTests
await _context.SaveChangesAsync();
_context.AppUser.Add(new AppUser()
{
Bookmarks = new List<AppUserBookmark>()
{
new AppUserBookmark()
{
AppUserId = 1,
ChapterId = 1,
Page = 1,
FileName = "1/1/1/0001.jpg",
SeriesId = 1,
VolumeId = 1
},
new AppUserBookmark()
{
AppUserId = 1,
ChapterId = 1,
Page = 2,
FileName = "1/1/1/0002.jpg",
SeriesId = 1,
VolumeId = 1
}
}
});
await _context.SaveChangesAsync();
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
var cleanupService = new CleanupService(_logger, _unitOfWork, _messageHub,
ds);
await cleanupService.CleanupBookmarks();
Assert.Equal(2, ds.GetFiles(BookmarkDirectory, searchOption:SearchOption.AllDirectories).Count());
}
[Fact]
public async Task CleanupBookmarks_LeavesOneFiles()
{
var filesystem = CreateFileSystem();
filesystem.AddFile($"{BookmarkDirectory}1/1/1/0001.jpg", new MockFileData(""));
filesystem.AddFile($"{BookmarkDirectory}1/1/2/0002.jpg", new MockFileData(""));
// Delete all Series to reset state
await ResetDB();
_context.Series.Add(new Series()
{
Name = "Test",
Library = new Library() {
Name = "Test LIb",
Type = LibraryType.Manga,
},
Volumes = new List<Volume>()
{
new Volume()
{
Chapters = new List<Chapter>()
{
new Chapter()
{
}
}
}
}
});
await _context.SaveChangesAsync();
_context.AppUser.Add(new AppUser()
{
Bookmarks = new List<AppUserBookmark>()
@ -426,7 +498,7 @@ public class CleanupServiceTests
await cleanupService.CleanupBookmarks();
Assert.Equal(1, ds.GetFiles(BookmarkDirectory, searchOption:SearchOption.AllDirectories).Count());
Assert.Equal(1, ds.FileSystem.Directory.GetDirectories($"{BookmarkDirectory}1/1/").Length);
}
#endregion