getmango / Mango

Mango is a self-hosted manga server and web reader
https://getmango.app
MIT License
1.69k stars 120 forks source link

[Bug Report] Changes in `library_path` in config being ignored #265

Closed NaruZosa closed 2 years ago

NaruZosa commented 2 years ago

Describe the bug Scanning reports an empty library. This occurs even with manga downloaded via the Mango plugins that

To Reproduce Steps to reproduce the behavior:

  1. Install Mango
  2. Change Admin password (unlikely this had any effect)
  3. Change library path
  4. Perform a manual scan, or wait for the automatic scan

Expected behavior Manga in the new path should be found

Environment (please complete the following information):

Docker Default values, other than:

Additional context image image image image And inside the nhentai folder: image

hkalexling commented 2 years ago

Anything in the log when scanning?

NaruZosa commented 2 years ago

Not from what I can see:

[96m[DEBUG] [0m2022/01/23 14:19:41 | 200 GET /api/admin/thumbnail_progress 3.46ms
[96m[DEBUG] [0m2022/01/23 14:19:46 | 200 GET /api/admin/thumbnail_progress 4.47ms
[96m[DEBUG] [0m2022/01/23 14:19:51 | 200 GET /api/admin/thumbnail_progress 3.69ms
[96m[DEBUG] [0m2022/01/23 14:19:56 | 200 GET /api/admin/thumbnail_progress 4.2ms
[96m[DEBUG] [0m2022/01/23 14:20:01 | 200 GET /api/admin/thumbnail_progress 3.76ms
[96m[DEBUG] [0m2022/01/23 14:20:06 | 200 GET /api/admin/thumbnail_progress 4.12ms
[96m[DEBUG] [0m2022/01/23 14:20:11 | 200 GET /api/admin/thumbnail_progress 4.0ms
[96m[DEBUG] [0m2022/01/23 14:20:16 | 200 GET /api/admin/thumbnail_progress 4.34ms
[96m[DEBUG] [0m2022/01/23 14:20:21 | 200 GET /api/admin/thumbnail_progress 4.24ms
[96m[DEBUG] [0m2022/01/23 14:20:26 | 200 GET /api/admin/thumbnail_progress 3.72ms
[96m[DEBUG] [0m2022/01/23 14:20:31 | 200 GET /api/admin/thumbnail_progress 3.13ms
[96m[DEBUG] [0m2022/01/23 14:20:36 | 200 GET /api/admin/thumbnail_progress 3.75ms
[96m[DEBUG] [0m2022/01/23 14:20:41 | 200 GET /api/admin/thumbnail_progress 4.78ms
[96m[DEBUG] [0m2022/01/23 14:20:47 | 200 GET /api/admin/thumbnail_progress 3.88ms
[96m[DEBUG] [0m2022/01/23 14:20:52 | 200 GET /api/admin/thumbnail_progress 3.75ms
[96m[DEBUG] [0m2022/01/23 14:20:57 | 200 GET /api/admin/thumbnail_progress 3.65ms
[96m[DEBUG] [0m2022/01/23 14:21:02 | 200 GET /api/admin/thumbnail_progress 3.93ms
[96m[DEBUG] [0m2022/01/23 14:21:07 | 200 GET /api/admin/thumbnail_progress 4.45ms
[96m[DEBUG] [0m2022/01/23 14:21:12 | 200 GET /api/admin/thumbnail_progress 4.2ms
[96m[DEBUG] [0m2022/01/23 14:21:17 | 200 GET /api/admin/thumbnail_progress 3.58ms
[96m[DEBUG] [0m2022/01/23 14:21:22 | 200 GET /api/admin/thumbnail_progress 3.63ms
[96m[DEBUG] [0m2022/01/23 14:21:27 | 200 GET /api/admin/thumbnail_progress 4.21ms
[96m[DEBUG] [0m2022/01/23 14:21:32 | 200 GET /api/admin/thumbnail_progress 3.75ms
[96m[DEBUG] [0m2022/01/23 14:21:37 | 200 GET /api/admin/thumbnail_progress 4.21ms
[96m[DEBUG] [0m2022/01/23 14:21:42 | 200 GET /api/admin/thumbnail_progress 3.22ms
[96m[DEBUG] [0m2022/01/23 14:21:47 | 200 GET /api/admin/thumbnail_progress 3.75ms
[96m[DEBUG] [0m2022/01/23 14:21:52 | 200 GET /api/admin/thumbnail_progress 3.22ms
[96m[DEBUG] [0m2022/01/23 14:21:57 | 200 GET /api/admin/thumbnail_progress 3.7ms
[96m[DEBUG] [0m2022/01/23 14:22:00 | 200 GET / 12.5ms
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /css/mango.css 2.43ms
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/common.js 199.67µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/dots.js 55.16µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/alert.js 30.84µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/title.js 83.94µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /css/mango.css 2.43ms
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/common.js 199.67µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/dots.js 55.16µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/alert.js 30.84µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /js/title.js 83.94µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /img/icon.png 357.02µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /img/nav-parent-close.svg 49.4µs
[96m[DEBUG] [0m2022/01/23 14:22:01 | 200 GET /favicon.ico 299.42µs
[96m[DEBUG] [0m2022/01/23 14:22:02 | 200 GET /api/admin/thumbnail_progress 3.28ms
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /admin 12.8ms
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /css/mango.css 2.74ms
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /js/common.js 150.79µs
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /js/admin.js 74.55µs
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /admin 12.8ms
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /css/mango.css 2.74ms
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /js/common.js 150.79µs
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /js/admin.js 74.55µs
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /img/icon.png 320.35µs
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /api/admin/thumbnail_progress 3.18ms
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /img/nav-parent-close.svg 32.18µs
[96m[DEBUG] [0m2022/01/23 14:22:04 | 200 GET /img/form-select.svg 36.84µs
[96m[DEBUG] [0m2022/01/23 14:22:06 | Current version: 11
[96m[DEBUG] [0m2022/01/23 14:22:06 | Target version: 11
[96m[DEBUG] [0m2022/01/23 14:22:06 | Nothing to be done
[93m[INFO] [0m2022/01/23 14:22:06 | Scanned 0 titles in 2.922358ms
[96m[DEBUG] [0m2022/01/23 14:22:06 | 200 POST /api/admin/scan 8.14ms
[96m[DEBUG] [0m2022/01/23 14:22:06 | Caching library to /root/mango/library.yml.gz
[96m[DEBUG] [0m2022/01/23 14:22:07 | 200 GET /api/admin/thumbnail_progress 4.26ms
[96m[DEBUG] [0m2022/01/23 14:22:09 | 200 GET /api/admin/thumbnail_progress 2.55ms
[96m[DEBUG] [0m2022/01/23 14:22:13 | 200 GET /api/admin/thumbnail_progress 3.59ms
NaruZosa commented 2 years ago

On a related note, any idea why there's so many "200 GET /api/admin/thumbnail_progress"?

It also sends me to 'http://192.168.1.151:9000/api/admin/thumbnail_progress' when the container is restarted and I log back in, which is json containing 'progress: 0'

image

hkalexling commented 2 years ago

I tried but couldn't reproduce the issue :( The nhentai plugin and the scanner work perfectly fine in Docker for me. I used Docker directly and not Unraid but it should be the same. Does recreating the container from scratch help?

Re your second comment:

  1. The thumbnail generation progress on the admin page updates automatically, so it sends a request to that endpoint every 5 seconds while you are on the page. Yes we could have used socket for it but I don't think it's a big deal.
  2. When you visit any page without a valid auth token, Mango redirects you to the login page, and after a successful login you will be redirected back to the page you requested. In your case, you were still on the admin page when the container restarted, and the browser was still sending requests to the progress endpoint. So when the container came back online you were sent to the login page and then redirected to the page you last requested, which happened to be the JSON API.
NaruZosa commented 2 years ago

I just stopped the container, deleted all contents in /root/mango (except the plugins folder), started the container back up and huzzah!:

[NONE] 2022/01/23 14:53:59 | Initial user created. You can log in with {"username" => "admin", "password" => "3bfe998ee0da41b9a213c03567b22139"}
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to CreateUsers (1)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to CreateIds (2)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to CreateThumbnails (3)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to CreateTags (4)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to CreateTitles (5)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to ForeignKeys (6)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to IDSignature (7)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to RelativePath (8)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to UnavailableIDs (9)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to RelativePathFix (10)
[93m[INFO] [0m2022/01/23 14:53:59 | Migrating to CreateMangaDexAccount (11)
[93m[INFO] [0m2022/01/23 14:53:59 | Job done
[93m[INFO] [0m2022/01/23 14:53:59 | Scanned 2 titles in 228.296513ms
[91m[ERROR] [0m2022/01/23 14:54:38 | Nil assertion failed
[93m[INFO] [0m2022/01/23 14:54:59 | Starting thumbnail generation
[93m[INFO] [0m2022/01/23 14:55:31 | Thumbnail generation finished
NaruZosa commented 2 years ago

To try to reproduce, I've now done the following:

Stopped the container Deleted the configuration and /root/mango

Started the container so it's a 'fresh' installation Stopped the container to edit the config Edited the config (changed library_path to /Manga) Started the container

And got the following:

The config file /root/.config/mango/config.yml does not exist. Dumping the default config there.
The config file has been created at /root/.config/mango/config.yml.
[NONE] 2022/01/23 14:58:38 | Initial user created. You can log in with {"username" => "admin", "password" => "REDACTED"}
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to CreateUsers (1)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to CreateIds (2)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to CreateThumbnails (3)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to CreateTags (4)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to CreateTitles (5)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to ForeignKeys (6)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to IDSignature (7)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to RelativePath (8)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to UnavailableIDs (9)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to RelativePathFix (10)
[93m[INFO] [0m2022/01/23 14:58:38 | Migrating to CreateMangaDexAccount (11)
[93m[INFO] [0m2022/01/23 14:58:38 | Job done
[93m[INFO] [0m2022/01/23 14:58:38 | The library directory /root/mango/library does not exist. Attempting to create it
[93m[INFO] [0m2022/01/23 14:58:38 | Scanned 0 titles in 5.269342ms
[93m[INFO] [0m2022/01/23 14:59:38 | Starting thumbnail generation
[93m[INFO] [0m2022/01/23 14:59:38 | Thumbnail generation finished

_| _|
_|_| _|_| _|_|_| _|_|_| _|_|_| _|_|
_| _| _| _| _| _| _| _| _| _| _|
_| _| _| _| _| _| _| _| _| _|
_| _| _|_|_| _| _| _|_|_| _|_|
_|
_|_|

Mango - Manga Server and Web Reader. Version 0.24.0

[93m[INFO] [0m2022/01/23 15:02:40 | Scanned 0 titles in 7.411764ms
[93m[INFO] [0m2022/01/23 15:03:40 | Starting thumbnail generation
[93m[INFO] [0m2022/01/23 15:03:40 | Thumbnail generation finished

Then I stopped the container, deleted the /root/mango contents, started the container and received Scanned 2 titles in 329.013149ms

Seems like it's caching the old location.

hkalexling commented 2 years ago

I am confused - you mentioned that you "Edited the config (changed library_path to /Manga)", but according to the log, the config file did not exist and Mango had to create one with the default values. Are you sure the config directory was correctly mapped?

NaruZosa commented 2 years ago

My apologies, I was unclear.

The log was for all of the following:

  1. Started the container so it's a 'fresh' installation
  2. Stopped the container to edit the config
  3. Edited the config (changed library_path to /Manga)
  4. Started the container

So the first section is the 'fresh' run (dot point 1), where the config was generated.

After [93m[INFO] [0m2022/01/23 14:59:38 | Thumbnail generation finished I then I performed dot points 2-4, and received [93m[INFO] [0m2022/01/23 15:02:40 | Scanned 0 titles in 7.411764ms.

The configuration was definitely correctly mapped. Closing the container, deleting the contents of '/root/mango' and restarting the container respects the library path specified in the config.

hkalexling commented 2 years ago

Ah yes now it makes sense, and I was able to reproduce it. Looks like it's an edge case that didn't get handled correctly by the new library cache feature added in v0.24.0. An easier workaround is to delete the library.yml.gz file instead of the whole /root/mango folder.

mango-assistant[bot] commented 2 years ago

Hi there! The issue has been fixed in v0.25.0. Thanks for the bug report!