Skip to content

Prefetch - #62

Open
antonp2k wants to merge 3 commits into
rgcsekaraa:mainfrom
antonp2k:prefetch
Open

antonp2k wants to merge 3 commits into
rgcsekaraa:mainfrom
antonp2k:prefetch

Conversation

@antonp2k

Copy link
Copy Markdown
Contributor

Local preview cache

Previewed and prefetched images, PDFs and text files are now saved on disk. Next time, the app can show the local copy and does not download the file again.

How it works

  • Files are saved in the app cache folder as preview-cache/files/<profile id>/<bucket>/<object key>, in the same folder structure as on the server.
  • When a file is opened, the app checks its size, modification date and ETag on S3 with one HEAD request.
  • If all three match the local copy, the local copy is shown.
  • If they do not match, the app downloads the new version and replaces the old copy.
  • If S3 is not reachable, the app shows the last local copy with an "Offline copy" label.
  • Video and audio are not cached. They are still streamed from S3.

Settings

  • The cache can be turned on or off.
  • Size limit: 1 GB by default. When the cache is full, the least recently used files are removed.
  • A "Clear" button removes all cached files.

Other changes

  • Saving a text file removes its local copy.
  • Deleting a profile removes its cached files.
  • On startup, broken and unused files are removed.
  • Tauri's asset protocol is turned on, but only for the cache folder.

Tests

  • New Rust unit tests for the cache.
  • New frontend unit tests for the cache logic.
  • A new smoke test for a matching copy, a changed file and offline mode.
  • All existing tests pass.

Why

Previewing files loads file every time. Prefetching and caching allows much faster browsing.

Scope

  • Frontend
  • Rust backend
  • CI/CD
  • Docs

Verification

  • Tested locally
  • Added or updated docs
  • Added or updated tests where needed

Notes

Include screenshots, logs, or rollout notes if useful.

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

Successfully merging this pull request may close these issues.

1 participant