gotson / komga

Media server for comics/mangas/BDs/magazines/eBooks with API, OPDS and Kobo Sync support
https://komga.org
MIT License
4.09k stars 243 forks source link

[Bug] Empty Trash option isn't library specific #612

Closed Kussie closed 3 years ago

Kussie commented 3 years ago

Komga environment

Describe the bug

I have two libraries, "action" (02014MR2Q40SF) and "adventure" (02014PJDK491P). If i delete a series from the "action" library and scan files, my deleted series shows up as unavailable as expected. If i open the context menu of the "adventure" library (By clicking the three dots) and choose "Empty Trash" the series in the "action" library is removed from Komga.

Expected behavior

The deleted series in the "action" library should not have been removed.

Actual behavior

The context menu should only empty the trash of the selected library. Which the warning popup implies is going to happen.

2021-08-12 15:41:49.695  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.komga.application.tasks.TaskHandler  : Executing task: ScanLibrary(libraryId=02014MR2Q40SF)
2021-08-12 15:41:49.696  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.d.service.LibraryContentLifecycle  : Updating library: Library(name=Action, root=file:/books/action/, importComicInfoBook=true, importComicInfoSeries=true, importComicInfoCollection=true, importComicInfoReadList=true, importEpubBook=true, importEpubSeries=true, importMylarSeries=true, importLocalArtwork=true, importBarcodeIsbn=true, scanForceModifiedTime=false, scanDeep=false, repairExtensions=false, convertToCbz=false, emptyTrashAfterScan=false, seriesCover=FIRST, id=02014MR2Q40SF, createdDate=2020-07-18T08:51:16, lastModifiedDate=2020-07-18T08:51:16)
2021-08-12 15:41:49.696  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.FileSystemScanner   : Scanning folder: /books/action
2021-08-12 15:41:49.696  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.FileSystemScanner   : Supported extensions: [cbz, zip, cbr, rar, pdf, epub]
2021-08-12 15:41:49.696  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.FileSystemScanner   : Excluded patterns: [#.yacreaderlibrary]
2021-08-12 15:41:49.696  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.FileSystemScanner   : Force directory modified time: false
2021-08-12 15:41:49.740  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.FileSystemScanner   : Scanned 5 series, 317 books, and 5 sidecars in 43.9ms
2021-08-12 15:41:49.741  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.d.service.LibraryContentLifecycle  : Soft deleting series not on disk anymore: [Series(name=6 Weapons, url=file:/books/action/6%20Weapons/, fileLastModified=2021-08-12T15:36:58.442, id=05XMYG22VXMCV, libraryId=02014MR2Q40SF, bookCount=2, deletedDate=null, createdDate=2021-08-12T15:41:09, lastModifiedDate=2021-08-12T15:41:09.516)]
2021-08-12 15:41:49.741  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.SeriesLifecycle     : Soft delete series: [Series(name=6 Weapons, url=file:/books/action/6%20Weapons/, fileLastModified=2021-08-12T15:36:58.442, id=05XMYG22VXMCV, libraryId=02014MR2Q40SF, bookCount=2, deletedDate=null, createdDate=2021-08-12T15:41:09, lastModifiedDate=2021-08-12T15:41:09.516)]
2021-08-12 15:41:49.741  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.komga.domain.service.BookLifecycle   : Soft delete books: [Book(name=6 Weapons - 1, url=file:/books/action/6%20Weapons/6%20Weapons%20-%201.cbz, fileLastModified=2021-08-12T15:36:58.273, fileSize=1767095, fileHash=9oomep, number=1, id=05XMYG22VXMCW, seriesId=05XMYG22VXMCV, libraryId=02014MR2Q40SF, deletedDate=null, createdDate=2021-08-12T15:41:09, lastModifiedDate=2021-08-12T15:41:10.479), Book(name=6 Weapons - 2, url=file:/books/action/6%20Weapons/6%20Weapons%20-%202.cbz, fileLastModified=2021-08-12T15:36:58.420, fileSize=2323749, fileHash=1arzpvv, number=2, id=05XMYG22VXMCX, seriesId=05XMYG22VXMCV, libraryId=02014MR2Q40SF, deletedDate=null, createdDate=2021-08-12T15:41:09, lastModifiedDate=2021-08-12T15:41:10.496)]
2021-08-12 15:41:49.774  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.d.s.SeriesCollectionLifecycle      : Deleting empty collections
2021-08-12 15:41:49.774  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.ReadListLifecycle   : Deleting empty read lists
2021-08-12 15:41:49.775  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.d.service.LibraryContentLifecycle  : Library updated in 79.0ms
2021-08-12 15:41:49.776  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.komga.application.tasks.TaskHandler  : Task ScanLibrary(libraryId=02014MR2Q40SF) executed in 80.2ms
2021-08-12 15:41:58.826  INFO 1 --- [http-nio-8080-exec-71] o.g.k.application.tasks.TaskReceiver     : Sending task: EmptyTrash(libraryId='02014PJDK491P', priority='6')
2021-08-12 15:41:58.830  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.komga.application.tasks.TaskHandler  : Executing task: EmptyTrash(libraryId='02014PJDK491P', priority='6')
2021-08-12 15:41:58.831  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.d.service.LibraryContentLifecycle  : Empty trash for library: Library(name=Adventure, root=file:/books/adventure/, importComicInfoBook=true, importComicInfoSeries=true, importComicInfoCollection=true, importComicInfoReadList=true, importEpubBook=true, importEpubSeries=true, importMylarSeries=true, importLocalArtwork=true, importBarcodeIsbn=true, scanForceModifiedTime=false, scanDeep=false, repairExtensions=false, convertToCbz=false, emptyTrashAfterScan=false, seriesCover=FIRST, id=02014PJDK491P, createdDate=2020-07-18T08:51:31, lastModifiedDate=2020-07-18T08:51:31)
2021-08-12 15:41:58.831  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.SeriesLifecycle     : Delete series ids: [05XMYG22VXMCV]
2021-08-12 15:41:58.832  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.komga.domain.service.BookLifecycle   : Delete book ids: [05XMYG22VXMCW, 05XMYG22VXMCX]
2021-08-12 15:41:58.965  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.komga.domain.service.BookLifecycle   : Delete book ids: []
2021-08-12 15:41:58.966  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.d.s.SeriesCollectionLifecycle      : Deleting empty collections
2021-08-12 15:41:58.967  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.k.domain.service.ReadListLifecycle   : Deleting empty read lists
2021-08-12 15:41:58.968  INFO 1 --- [org.springframework.jms.JmsListenerEndpointContainer#1-1] o.g.komga.application.tasks.TaskHandler  : Task EmptyTrash(libraryId='02014PJDK491P', priority='6') executed in 137ms

The logs for the empty trash task reference the libraryId of my "adventure" library. However it still removes books from my "action" library.

https://user-images.githubusercontent.com/4960791/129145383-9452d485-2167-42d1-91aa-028ee7fc3412.mp4

gotson commented 3 years ago

Looking at the code I forgot to add the condition to search by library šŸ™ƒ šŸ¤¦šŸ»

Kussie commented 3 years ago

That'll do it :P

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 0.116.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: