cryptomator / cryptofs

Java Filesystem Provider with integrated encryption
GNU Affero General Public License v3.0
93 stars 35 forks source link

refactor chunk cache #161

Closed overheadhunter closed 1 year ago

overheadhunter commented 1 year ago

This is a new attempt of fixing #158 while retaining the ability to concurrently read from the same open file.

The ChunkCache will now make sure not to recycle any chunk as long as it is still being used ("active chunk" - using reference counting and AutoCloseable). When no longer active, chunks are moved to a "stale" cache, invalidating LRU chunks eventually.

overheadhunter commented 1 year ago

Slightly off-topic: This also fixes #160 (should already be fixed in #48). It has been wrong all the time, but apparently the error didn't occur during tests with the old implementation, therefore I decided to include this in this PR.