Skip to content

Commit

Permalink
Add Delete Fn in Cache pkg (#1365)
Browse files Browse the repository at this point in the history
* Add Delete Fn in Cache pkg

* fmt

Co-authored-by: Nathan Seva <[email protected]>

* fmt

Co-authored-by: Nathan Seva <[email protected]>

* test codecov-action@v4

* inexistence is a success

Co-authored-by: Thomas Sénéchal <[email protected]>

---------

Co-authored-by: Nathan Seva <[email protected]>
Co-authored-by: Thomas Sénéchal <[email protected]>
  • Loading branch information
3 people authored Aug 14, 2024
1 parent 3103e69 commit 9abe688
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,22 @@ 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 {
if os.IsNotExist(err) {
return nil
}

return fmt.Errorf("while deleting from cache: %w", err)
}

return nil
}

0 comments on commit 9abe688

Please sign in to comment.