diff options
-rw-r--r-- | internal/vfs/zip/archive.go | 6 | ||||
-rw-r--r-- | internal/vfs/zip/vfs.go | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go index 561eb22b..85c84a9f 100644 --- a/internal/vfs/zip/archive.go +++ b/internal/vfs/zip/archive.go @@ -227,3 +227,9 @@ func (a *zipArchive) Readlink(ctx context.Context, name string) (string, error) // only return the n bytes read from the link return string(symlink[:n]), nil } + +// onEvicted called by the zipVFS.cache when an archive is removed from the cache +func (a *zipArchive) onEvicted(){ + metrics.ZipServingArchivesCurrentlyCached.Dec() + metrics.ZipServingFilesPerZipArchiveCurrentlyCached.Sub(float64(len(a.files))) +} diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go index ec67e936..9ba6f859 100644 --- a/internal/vfs/zip/vfs.go +++ b/internal/vfs/zip/vfs.go @@ -36,9 +36,7 @@ func New() vfs.VFS { } zipVFS.cache.OnEvicted(func(s string, i interface{}) { - zipArchive := i.(*zipArchive) - - metrics.ZipServingFilesPerZipArchiveCurrentlyCached.Sub(float64(len(zipArchive.files))) + i.(*zipArchive).onEvicted() }) return zipVFS |