BobbyWibowo / lolisafe

Blazing fast file uploader and awesome bunker written in node! 🚀
MIT License
317 stars 56 forks source link

Disabling file cache identifiers should disable stricter collision check altogether #12

Closed BobbyWibowo closed 5 years ago

BobbyWibowo commented 5 years ago

Even when caching is disabled, at the moment it's still programmed to read file list of the uploads directory on EVERY new uploads. In the end it'll still require more memory, albeit temporarily. But I was thinking, if multiple new uploads happen in a short period of time, it's likely that memory usage during that time will be even worse than when caching is enabled, as each attempt to read file list is in its own task. As far as I know, they will not be removed from memory at the instant the session ends, but instead only after a period of time by the garbage collector (I may be wrong, I haven't read too deep into how Node's memory management works).

So yeah, I think it's better to just disable stricter collision check altogether when caching is disabled. Basically it will fallback to its old behavior before this commit https://github.com/BobbyWibowo/lolisafe/commit/6543a87b11036a27dc32e58e6016625179ba279c.

Of course, when it's disabled then collisions such as "abcd.jpg" and "abcd.png" existing at the same time will then be able to occur again, and thus cause both files to only have a single thumbnail (remember, thumbnail will only be saved as a PNG file, regardless of the original file's extension - both files will then use thumbnail of the file that was uploaded the earliest), but people should enable caching anyways when they don't want that occur. While those that don't even use thumbnails can instead choose to disable caching to reduce unnecessary memory usage.

On a side note, this is this fork's first issue. All this time I forgot to enable Issues, kek.

BobbyWibowo commented 5 years ago

Closed https://github.com/BobbyWibowo/lolisafe/commit/2fab5becb0bac3bfda4edd0b8dc00f3b065c16eb.