filepreviewjob: Perform the cache operations off the main thread

Despite the parallelisation of PreviewJob, it had a limited effect when everything was in the cache or needed saving to the cache as both of these stalled the main thread.


filepreviewjob: Move generic preamble out of cache lookup method

A subtle behaviour change is that failing to resolve a local file path
to it's original path will now result in an error, but generation would
probably fail in that case anyway.

filepreviewjob: move thumbnail validity check to a new method

filepreviewjob: Move saving of thumbnails to a new thread

Saving pngs is a relatively costly operation. As it's just a cache for
the next usage, there is no reason to block the main thread or delay the
job from completing.

filepreviewjob: Load cached thumbnail in a worker thread

Loading even a small png still consumes the thread.

Given PreviewJob is an async API we can safely offload it to a worker
thread. We rely on PreviewJob to be limit concurrent activities.

If the FilePreviewJob is killed mid-operation, the worker thread will
continue loading the image but harmlessly discard the image at the end.

Merge request reports

Loading