sbs20 / scanservjs

SANE scanner nodejs web ui
https://sbs20.github.io/scanservjs/
GNU General Public License v2.0
766 stars 145 forks source link

Added thumbnail caching #635

Closed sbs20 closed 1 year ago

sbs20 commented 1 year ago

This pull request adds thumbnail caching, which is very much needed for low power devices such as the raspberry pi.

The thumbnail is generated only when requested and will be deleted when the file is deleted.

Closes #433 Builds on original implementation in #592

Leone25 commented 1 year ago

Hey sorry to bother, but I just noticed two main differences between your version and my version:

  1. you are saving before sending the thumbnail (if the thumbnail isn't yet generated)
  2. you are using a sync write/read when writing/reading the thumbnail

I had made the async versions of those two commands especially because I didn't want to block the main thread when doing those operations, why did you switch back? I'm just curious

sbs20 commented 1 year ago

Hello!

Not a bother 😄

  1. Yes, I suppose it's slightly different. I wanted to avoid mixing .then(...) and await. I didn't feel strongly about the order
  2. It would be better not to block the main thread, you're correct. But I was in the middle of a fairly massive refactoring and wanted to keep the number of paths through the application at an absolute minimum. I prioritised re-using code which was already there and working over non-blocking. I do intend to remove all the sync methods, but wanted to get everything else out of the way first.