Cache: `unexpected conditions during reading` issues

There were a couple of mentions in the forums about various errors that started with unexpected conditions during reading. I assumed that those were invalid caches from older versions. That’s still a possibility however:
Recently, this happened to me as well and since I knew I wasn’t using an old cache version, I started to investigate.

It seems that when using -temp-path and files will be copied with the same name but different content (Plex agents do this very often with subtitles, especially for new releases), cache will keep the old cached data but refresh the metadata (size, has etc).
Reading from these files would have ended unexpected since the data didn’t match anymore.

Suffice to say, cache is now deleting cached data (if it exists) when it will receive a cloud notification to ensure that it will read a likely updated file from the cloud provider.

In the future, it’s perhaps better if it will actually cache rather than delete it to save some bandwidth but I wanted this bug fixed first.

Beta with the fix:

1 Like

Thanks for this, giving it a trial now on two servers.

You will need to purge the cache or purge the exact files that have this issue as the “old” version of the file data will be in the cache

Done, purged the cache to test. I noticed this happen once or twice when a ‘proper’ upgrade happened with the same filename.

Looking bad I can see some errors as well. I installed and am testing as well.