babluboy / bookworm

A simple ebook reader for Elementary OS
GNU General Public License v3.0
1.32k stars 101 forks source link

Every time an e-book is opened a new data base row is created #373

Open aTom3333 opened 2 years ago

aTom3333 commented 2 years ago

Let's say I have an e-book file test.epub and my bookworm.db is empty.

babluboy commented 2 years ago

Thanks for the detailed issue. As far as I remember, a new row is created if the filepath+file name combination does not exist. So will check why a second row is getting created

aTom3333 commented 2 years ago

If it helps, the way I am using the application is by double clicking on my epub file (which does com.github.babluboy.bookworm /absolute/path/to/my.epub) and not by browsing my library using bookworm.

The callstack at the point where the row is added in the database is:

#0  bookworm_app_db_addBookToDataBase (aBook=) at ../../../../../../Programmation/Vala/bookworm/src/database.vala:337
#1  0x00005555555ce594 in bookworm_app_library_addBookToLibrary (aBook=) at ../../../../../../Programmation/Vala/bookworm/src/library.vala:590
#2  0x00005555555ce1d1 in bookworm_app_library_addBooksToLibrary_co (_data_=0x555555f3e010) at ../../../../../../Programmation/Vala/bookworm/src/library.vala:569
#3  0x00005555555cd5ad in bookworm_app_library_addBooksToLibrary (_callback_=0x0, _user_data_=0x0) at ../../../../../../Programmation/Vala/bookworm/src/library.vala:21
#4  0x0000555555570913 in bookworm_app_bookworm_real_activate (base=0x55555585a120) at ../../../../../../Programmation/Vala/bookworm/src/bookworm.vala:274
#5  0x00007ffff7258969 in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff7271339 in g_signal_emit_valist () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff727155f in g_signal_emit () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x000055555556fad9 in bookworm_app_bookworm_real_command_line (base=0x55555585a120, command_line=0x555555b3f7a0) at ../../../../../../Programmation/Vala/bookworm/src/bookworm.vala:145
#9  0x00007ffff7322efd in  () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#10 0x00007ffff7258969 in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff727069b in g_signal_emit_valist () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00007ffff727155f in g_signal_emit () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#13 0x00007ffff737f563 in  () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#14 0x00007ffff7381f59 in  () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#15 0x00007ffff73820de in g_application_run () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#16 0x000055555556f738 in _vala_main (args=0x7fffffffe6a8, args_length1=2) at ../../../../../../Programmation/Vala/bookworm/src/main.vala:38
#17 0x000055555556f760 in main (argc=2, argv=0x7fffffffe6a8) at ../../../../../../Programmation/Vala/bookworm/src/main.vala:20
aTom3333 commented 2 years ago

Indeed, the issue doesn't occur when I simply run bookworm alone (equivalent to running com.github.babluboy.bookworm). In that case my last e-book is opened and no new row is created. So it seems the way I used bookworm isn't supported

babluboy commented 2 years ago

Yes, based on the HIG of elementary OS and also Apple, specific software should be used to explore, open and work with concerned file types.

however the way you used bookworm is also something which can be adapted. While I had some code to deal with double click of e-books to add them to bookworm, I can improve it to do some checks to first check if the ebook is already added and handle the scenario by opening the book at the required content

Will keep this issue open to improve the behaviour and avoid the issue you have highlighted