Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the addbooks command on books already imported results in duplicated cover files #87

Open
adborden opened this issue Apr 16, 2017 · 2 comments
Labels

Comments

@adborden
Copy link
Member

I have about 140 books already imported and each time I run the addbooks command, my static_media grows by 0.9GB. It looks like the cover files get copied even though the book isn't going to be imported.

$ ls static_media/covers
foxgeeseancientn00weiriala_1.gif
foxgeeseancientn00weiriala_2.gif
foxgeeseancientn00weiriala_3.gif
foxgeeseancientn00weiriala_4.gif
foxgeeseancientn00weiriala_5.gif
foxgeeseancientn00weiriala.gif

You can see multiple copies of the same cover file. Each time I run addbooks, a new one is created.

I think this would be fixed if instead of the current "save and check error" strategy, we move to a "check if exists then save" strategy we would avoid the save logic that duplicates the cover file.

@adborden adborden added the Bug label Apr 16, 2017
@adborden
Copy link
Member Author

Side note, it's okay in some scenarios to create extra files but we would want to include a cleanup job to find orphaned cover files.

@adborden adborden changed the title Running the addbooks command on books already import results in duplicated cover files Running the addbooks command on books already imported results in duplicated cover files Apr 16, 2017
@murlock
Copy link
Contributor

murlock commented May 21, 2017

Hello, issue is in save() method of Book:
Cover is extracted before calling real save in DB:
by switching logic order, we can insure that cover will be saved only if insertion in DB was OK.

Of course, a cleanup job should be also nice since there is border case (like editing, removing or replacing an ebook).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants