Kareadita / Kavita

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
http://www.kavitareader.com
GNU General Public License v3.0
5.38k stars 271 forks source link

Bookmarks not saving. Can't change bookmark directory #2927

Closed cpetzel closed 4 weeks ago

cpetzel commented 1 month ago

What happened?

When saving a bookmark, it does not error. But when I click on the Bookmarks page, I see an empty list of bookmarks... When I go back to the same section in the book and attempt to save a bookmark, I get an error saying that this bookmark already exists... so why don't I see it?

I also cannot change my bookmark directory... I get a "device or resource busy" error message.

I am on a synology, with kavita created through docker.

version: "3.9"
services:
  kavita:
    image: jvmilazz0/kavita:latest
    container_name: Kavita
    hostname: kavita
    mem_limit: 4g
    cpu_shares: 768
    security_opt:
      - no-new-privileges:true
    ports:
      - 5471:5000
    volumes:
      - /volume3/Data3/kavita/config:/kavita/config:rw
      - /volume1/Data/books:/manga:rw
      - /volume3/Data3/kavita/bookmarks:/bookmarks:rw
    restart: on-failure:5

I think on synology, there might be a race condition with deleting the folder when checking permission? perhaps it cannot delete the "test.txt" file fast enough?

What did you expect?

When saving a bookmark, I can see it in the bookmarks page.

I also expect to be able to change the bookmark dir (mounted docker volume)

Kavita Version Number - If you don not see your version number listed, please update Kavita and see if your issue still persists.

0.8.1 - Stable

What operating system is Kavita being hosted from?

Docker (Other)

If the issue is being seen on Desktop, what OS are you running where you see the issue?

None

If the issue is being seen in the UI, what browsers are you seeing the problem on?

Chrome

If the issue is being seen on Mobile, what OS are you running where you see the issue?

None

If the issue is being seen on the Mobile UI, what browsers are you seeing the problem on?

No response

Relevant log output

System.IO.IOException: Device or resource busy : '/bookmarks'
   at System.IO.FileSystem.RemoveEmptyDirectory(String fullPath, Boolean topLevel, Boolean throwWhenNotEmpty)
   at System.IO.DirectoryInfo.Delete(Boolean recursive)
   at System.IO.Abstractions.DirectoryInfoWrapper.Delete(Boolean recursive)
   at API.Services.DirectoryService.ClearAndDeleteDirectory(String directoryPath) in /home/runner/work/Kavita/Kavita/API/Services/DirectoryService.cs:line 373
   at API.Services.DirectoryService.CheckWriteAccess(String directoryName) in /home/runner/work/Kavita/Kavita/API/Services/DirectoryService.cs:line 1017
   at API.Controllers.SettingsController.UpdateSettings(ServerSettingDto updateSettingsDto) in /home/runner/work/Kavita/Kavita/API/Controllers/SettingsController.cs:line 277
   at lambda_method4822(Closure, Object)


### Additional Notes

<img width="1501" alt="image" src="https://github.com/Kareadita/Kavita/assets/2036206/932bc110-19f2-4381-8433-5f61acef5a8a">
majora2007 commented 4 weeks ago

This sounds like a permissions issue to me. I would first verify where the config is mounted and then the permissions of those directories.

I don't recall if you can change the location on docker because you'd have to mount that location beforehand. Let's first fix your issues then move onto changing the directory on docker.

therobbiedavis commented 4 weeks ago

Shouldn't it be?

Maitresinh commented 4 weeks ago

i have the same problem on Unraid. Permissions seems ok Capture d'écran 2024-05-03 170810

majora2007 commented 4 weeks ago

I checked the code and there are no restrictions on Docker users changing the bookmarks directory. I'll test on my dev instance to make sure there is no regression.

cpetzel commented 4 weeks ago

There are two separate issues here. That bookmarks don't work out of the box. In an attempt to fix what might be a permission issue, I also can't change the bookmarks directory.

for the latter, when trying to change the bookmarks directory, here are my permissions for the mounted volume.

craig@nas:/volume3/Data3/kavita$ pwd
/volume3/Data3/kavita
craig@nas:/volume3/Data3/kavita$ ls -la
total 8
drwxrwxrwx+ 1 craig users   60 May  3 00:09 .
drwxrwxrwx+ 1 root  root   292 May  2 22:27 ..
drwxrwxrwx+ 1 craig users    0 May  3 00:11 bookmarks
drwxrwxrwx+ 1 craig users  190 May  3 09:19 config
-rwxrwxrwx+ 1 craig users 6148 May  3 00:09 .DS_Store
drwxrwxrwx+ 1 root  users   88 May  3 08:57 @eaDir

The program has no problem writing to the sibling directory (config).

I think the issue, is that the code is deleting the bookmarks directory... so it seems docker won't let you delete the root mounted directory. If I use a child directory under that import.. ex: - /volume3/Data3/kavita/bookmarkRoot:/bookmarkRoot:rw and then use /bookmarkRoot/bookmarks as my bookmark folder in the UI, then the admin panel lets me make that change!

However, bookmarks still do not appear to be written to disk. When saving a bookmark, I get no error in the UI, but I don't see any bookmarks... (this is true for OOTB, and also when I change my bookmarks directory).

looking at the logs, the first bookmark save is ok...

[Kavita] [2024-05-03 16:35:10.600 +00:00  3] [Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP GET /api/reader/ptoc?chapterId=7 responded 200 in 1.3384 ms

so it is making it into the DB... Then the next bookmark save (on the same text) fails

[Kavita] [2024-05-03 16:37:37.155 +00:00  64] [Information] Serilog.AspNetCore.RequestLoggingMiddleware HTTP POST /api/reader/create-ptoc responded 400 in 3.5946 ms

Duplicate bookmark entry already exists

So why are bookmarks making their way into the DB, but not showing anything in the UI or directory?

Maitresinh commented 4 weeks ago

Sorry to highkjack the thread. Do i have to open a separate one ?

majora2007 commented 4 weeks ago

@Maitresinh that would be great if you could open a separate issue.

@cpetzel Bookmarks work for me. The way I implemented them is that I enter it into the DB and then move the file. So the file isn't being able to copy from config/cache/ to config/bookmarks and even if it fails, it is already "in the db".

I'm thinking that the mount point might confuse Kavita. I recall that when you setup your libraries, you have to navigate to / first. Perhaps that is what's happening here?

@DieselTech or @therobbiedavis would one of you be willing to try this out for me?

cpetzel commented 4 weeks ago

I guess I'm not even able to see this file you speak of... After I create a bookmark, my bookmark directory is empty (when trying with both the OOTB default dir, and the updated mounted dir).

the only files I see in /config/cache, are folders with the epub file inside of it.

therobbiedavis commented 4 weeks ago

@DieselTech or @therobbiedavis would one of you be willing to try this out for me?

Looking into it now.

majora2007 commented 4 weeks ago

Wait @cpetzel are you talking about Personal Table of Contents also known as Bookmarks in Epub reader or Bookmarks from image-based reader?

Because they are 2 different things and work very different.

cpetzel commented 4 weeks ago

I was imagining bookmarks being like highlights.

image

image

The documentation does not tell you how to create bookmarks, but displays collections that have bookmarks, so I had assumed, if I create a bookmark, it would show up there...

But now that you mention this, I see that there is a bookmark section near the table of contents, and that my bookmarks are there! Sorry for the confusion. Maybe some clarification is needed in the documentation.

How would I add bookmarks as seen in the documentation?

majora2007 commented 4 weeks ago

Those image based bookmarks are for image-based media (archives/image). There is a button on top right or you can double tap the image.

We just launched the new wiki, so looks like not all the reader sections have been flushed out. I'll take note on the potential confusion point.

If you have anything else, feel free to comment, but going to close since you got it working.

cpetzel commented 4 weeks ago

Great! Thank you for the quick response, and helpful info! I really like the app so far!

Maitresinh commented 4 weeks ago

Same confusion for me. Not totally clear thought (My first language is not English)