diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-10-01 07:08:21 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-10-01 07:08:21 +0300 |
commit | aec30ca4632f31e4921ecdc16c9f583bf57e6cbc (patch) | |
tree | 617d6c42461cb0457df89074cfc4b0a4158c0f3b | |
parent | 5647c1c66fe707da97f091f42ec0b91d720d5258 (diff) |
Move onEvicted to zipArchive
-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 |