mcbeet / beet

The Minecraft pack development kit.
https://mcbeet.dev
MIT License
141 stars 15 forks source link

Calling MultiCache.clear() doesn't run the finalizers in the subcaches #352

Open vdvman1 opened 1 year ago

vdvman1 commented 1 year ago

The MultiCache.clear() method just deletes the folder and its content, and never calls the clear method of the individual caches within it, leading to the finalizers never being run

vberlier commented 1 year ago

Last time I checked it does run the finalizers though. The method also calls super().clear(), which invokes the implementation provided by python's MutableMapping abstract base class, which calls __delitem__ for each cache entry. The MultiCache calls the Cache.delete() method when caches are removed with __delitem__ so finalizers should run fine.

vdvman1 commented 1 year ago

What about lazily loaded caches that haven't yet been loaded?

vberlier commented 1 year ago

Ooh yeah you're right, I guess this could be fixed by calling self.preload() before doing anything in MultiCache.clear().