From 3399f982ae4eed22617585a7cf2c647a71df7c83 Mon Sep 17 00:00:00 2001 From: Phoebe Lartisant Date: Thu, 8 Aug 2024 16:29:08 +0200 Subject: [PATCH 1/5] Add Delete Fn in Cache pkg --- pkg/cache/cache.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index a50085fe3..32327c0d7 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -77,3 +77,19 @@ func (c *Cache) Save(fileName string, content []byte) error { return nil } + +// Delete removes a file from the cache. +func (c *Cache) Delete(fileName string) error { + + fullPath, err := fullPath(fileName, c.ConfigDir) + if err != nil { + return fmt.Errorf("while reading cached file %s: %w", fileName, err) + } + + err = os.Remove(fullPath) + if err != nil { + return fmt.Errorf("while deleting from cache: %v", err) + } + + return nil +} From 14d3d4a93c568060708b03e1ca0b268d8e64ca06 Mon Sep 17 00:00:00 2001 From: Pivi Lartisant Date: Fri, 9 Aug 2024 11:12:14 +0200 Subject: [PATCH 2/5] fmt Co-authored-by: Nathan Seva --- pkg/cache/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 32327c0d7..a54cfacf9 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -88,7 +88,7 @@ func (c *Cache) Delete(fileName string) error { err = os.Remove(fullPath) if err != nil { - return fmt.Errorf("while deleting from cache: %v", err) + return fmt.Errorf("while deleting from cache: %w", err) } return nil From 18cf0a0cc46d17a045dcd4d3d9b8dc1b347de193 Mon Sep 17 00:00:00 2001 From: Pivi Lartisant Date: Fri, 9 Aug 2024 11:12:24 +0200 Subject: [PATCH 3/5] fmt Co-authored-by: Nathan Seva --- pkg/cache/cache.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index a54cfacf9..9d2d1b2cd 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -80,7 +80,6 @@ func (c *Cache) Save(fileName string, content []byte) error { // Delete removes a file from the cache. func (c *Cache) Delete(fileName string) error { - fullPath, err := fullPath(fileName, c.ConfigDir) if err != nil { return fmt.Errorf("while reading cached file %s: %w", fileName, err) From 7c8fa9d0e4ea194133211730d0f58e73a438ca4f Mon Sep 17 00:00:00 2001 From: Phoebe Lartisant Date: Fri, 9 Aug 2024 12:08:55 +0200 Subject: [PATCH 4/5] test codecov-action@v4 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e21c9c7ce..6a8815c6d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,6 +16,6 @@ jobs: os: ${{ matrix.os }} repo-token: ${{ secrets.GITHUB_TOKEN }} - run: task test-coverage - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: files: coverage.coverprofile From 2bd32120d5d44c71fa61e78770231e5de2269db9 Mon Sep 17 00:00:00 2001 From: Pivi Lartisant Date: Wed, 14 Aug 2024 09:59:21 +0200 Subject: [PATCH 5/5] inexistence is a success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Sénéchal <44696378+thomas-senechal@users.noreply.github.com> --- pkg/cache/cache.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 9d2d1b2cd..9f5ceb628 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -87,6 +87,10 @@ func (c *Cache) Delete(fileName string) error { err = os.Remove(fullPath) if err != nil { + if os.IsNotExist(err) { + return nil + } + return fmt.Errorf("while deleting from cache: %w", err) }