Skip to content

Commit

Permalink
🐹 🐛 fix the check for the empty dir
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellodesales committed Jan 29, 2025
1 parent e34cd16 commit 603d851
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions internal/cachedirectory/cachedirectory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cachedirectory

import (
usererrors "errors"
"io"
"io/ioutil"
"os"
"path"
Expand Down Expand Up @@ -108,19 +107,17 @@ func (cacheDirectory *CacheDirectory) CheckOrCreateVersionFile(pull bool, versio
if !isAccessible {
return errors.Wrap(err, "Cache dir exists, but the current user can't write to it.")
}

isEmpty, err := isEmptyDirectory(cacheDirectory.path)
}
isEmpty, err := isEmptyDirectory(cacheDirectory.path)
if err != nil {
return err
}
if isEmpty {
err = ioutil.WriteFile(cacheVersionFilePath, []byte(version), 0644)
if err != nil {
return err
}
if isEmpty {
err = ioutil.WriteFile(cacheVersionFilePath, []byte(version), 0644)
if err != nil {
return errors.Wrap(err, "Could not create cache version file.")
}
return errors.Wrap(err, "Could not create cache version file.")
}
return nil

}
return usererrors.New(errorNotACacheOrEmpty)
}
Expand Down

0 comments on commit 603d851

Please sign in to comment.