diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-26 11:40:20 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-27 12:32:57 +0300 |
commit | 03141525f5311d36ab74c47f4c594bb4eb7e71a5 (patch) | |
tree | 393960dd3828a4d2ffbff7326824fa23aab75a07 | |
parent | ea9803dadadd5865a4d94165467a1e9b889a7fc3 (diff) |
housekeeping: Don't treat disappearing files as error
When performing housekeeping tasks, we try to remove various files from
the repository which are stale objects left behind by git. While removal
of these files isn't considered an error, we still log them and
increment the counter of such unremovable files.
Right now, we also treat `ErrNotExist` errors like this. That doesn't
make a whole lot of sense as we know that this file has been removed by
another process now, so this is rather a benign race and not an error.
So let's skip logging of any files which have been removed already.
-rw-r--r-- | internal/git/housekeeping/housekeeping.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/internal/git/housekeeping/housekeeping.go b/internal/git/housekeeping/housekeeping.go index 01755a283..e6b173c85 100644 --- a/internal/git/housekeeping/housekeeping.go +++ b/internal/git/housekeeping/housekeeping.go @@ -41,6 +41,9 @@ func Perform(ctx context.Context, repoPath string) error { unremovableFiles := 0 for _, path := range filesToPrune { if err := os.Remove(path); err != nil { + if os.IsNotExist(err) { + continue + } unremovableFiles++ // We cannot use `logEntry` here as it's already seeded // with the statistics fields. |