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

LCP LSD license update on Windows => book.epub disappear on app exit (instead of deleting immediately), and book.tmplcpl file remains #884

Closed
danielweck opened this issue Dec 12, 2019 · 5 comments

Comments

@danielweck
Copy link
Member

Seems like the bug persists: #787

@danielweck
Copy link
Member Author

Code culprit (no idea how to make the Windows filesystem happy ... our code releases file handles correctly as far as I can tell, it looks like there are stale file pointers hanging around because of how NodeJS implement filesystem access on Windows?):
https://github.com/readium/readium-desktop/blob/e9e2f52e35ef02c96f080d45760047d63bac2f0d/src/main/services/lcp.ts#L70-L102

@danielweck
Copy link
Member Author

One drastic solution would be to exit the app and restart it ... not the ideal UX though !

@danielweck
Copy link
Member Author

The problem only occurs when the book has been read at least once (i.e. streamer component accesses the ZIP resources). So it looks like the destroy/free function of streamer does not work because of a bug in the NodeJS stream/filesystem implementation on Windows (or maybe a bug in Yauzl, the ZIP library which is used to stream data out of the EPUB).
Regardless, there is a delayed file deletion on Windows, book.epub only disappears when the app exits. The good news is that the book.tmplcpl remains in the folder, so we could just rename it at a convenient time in order to work around the problem.

@danielweck danielweck changed the title LCP LSD license update on Windows => book.epub disappear on app exit, and book.tmplcpl file remains LCP LSD license update on Windows => book.epub disappear on app exit (instead of deleting immediately), and book.tmplcpl file remains Dec 12, 2019
@danielweck
Copy link
Member Author

[2]   readium-desktop:main#services/lcp Error: EPERM: operation not permitted, rename 'C:\Users\danie\AppData\Roaming\EDRLab.ThoriumReader\publications\35085bad-e0b8-4dc7-a9a9-93d01a2ceb62\book.epub.tmplcpl' -> 'C:\Users\danie\AppData\Roaming\EDRLab.ThoriumReader\publications\35085bad-e0b8-4dc7-a9a9-93d01a2ceb62\book.epub'
[2]   readium-desktop:main#services/lcp     at Object.renameSync (fs.js:609:3)
[2]   readium-desktop:main#services/lcp     at LcpManager.<anonymous> (C:\Users\danie\Desktop\readium-desktop\dist\main.js:7172:16)
[2]   readium-desktop:main#services/lcp     at Generator.next (<anonymous>)
[2]   readium-desktop:main#services/lcp     at fulfilled (C:\Users\danie\Desktop\readium-desktop\node_modules\tslib\tslib.js:107:62) +381ms
[2]   readium-desktop:main#services/lcp Error: EPERM: operation not permitted, rename 'C:\Users\danie\AppData\Roaming\EDRLab.ThoriumReader\publications\35085bad-e0b8-4dc7-a9a9-93d01a2ceb62\book.epub.tmplcpl' -> 'C:\Users\danie\AppData\Roaming\EDRLab.ThoriumReader\publications\35085bad-e0b8-4dc7-a9a9-93d01a2ceb62\book.epub'
[2]   readium-desktop:main#services/lcp     at Object.renameSync (fs.js:609:3)
[2]   readium-desktop:main#services/lcp     at LcpManager.<anonymous> (C:\Users\danie\Desktop\readium-desktop\dist\main.js:7172:16)
[2]   readium-desktop:main#services/lcp     at Generator.next (<anonymous>)
[2]   readium-desktop:main#services/lcp     at fulfilled (C:\Users\danie\Desktop\readium-desktop\node_modules\tslib\tslib.js:107:62) +1ms

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

No branches or pull requests

1 participant