fred icon indicating copy to clipboard operation
fred copied to clipboard

Simplify ArchiveManager archived entry cache

Open bertm opened this issue 1 year ago • 0 comments

The ArchiveManager is keeping track of cached entries in all kinds of different ways, with a lot of code paths being effectively unused.

  • It would try to keep track of whether the archive is still the same as when it was read last time, but there is no code path where that data is actually updated.
  • It would try to determine if ArchiveRestartException should be thrown for the above reason, but there is no code path where this can actually happen.
  • It would try to insert error entries into the cache when the archive file is too big to be cached, but the net effect is the same as when the entry would not be cached in the first place (it always returns a null result when queried).
  • It would keep track of cached items in two different ways, just to be able to unnecessarily clear the cache (and potentially leak memory while at it, as everything was referencing everything else).
  • It would use FreenetURI as a cache key, which is mutable and could break the cache when changed.

Move the cache implementation to a dedicated class that has proper unit tests, and remove all the code paths that were effectively no-op (ignoring a few log statements).

I would suggest to review this commit by commit. The first two commits contain the bulk of the work (their commit messages explain what is happening), the remaining four commit are simpler after the fact cleanups.

bertm avatar Dec 01 '24 16:12 bertm