Skip to content

Commit 603d851

Browse files
🐹 🐛 fix the check for the empty dir
1 parent e34cd16 commit 603d851

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

internal/cachedirectory/cachedirectory.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cachedirectory
22

33
import (
44
usererrors "errors"
5-
"io"
65
"io/ioutil"
76
"os"
87
"path"
@@ -108,19 +107,17 @@ func (cacheDirectory *CacheDirectory) CheckOrCreateVersionFile(pull bool, versio
108107
if !isAccessible {
109108
return errors.Wrap(err, "Cache dir exists, but the current user can't write to it.")
110109
}
111-
112-
isEmpty, err := isEmptyDirectory(cacheDirectory.path)
110+
}
111+
isEmpty, err := isEmptyDirectory(cacheDirectory.path)
112+
if err != nil {
113+
return err
114+
}
115+
if isEmpty {
116+
err = ioutil.WriteFile(cacheVersionFilePath, []byte(version), 0644)
113117
if err != nil {
114-
return err
115-
}
116-
if isEmpty {
117-
err = ioutil.WriteFile(cacheVersionFilePath, []byte(version), 0644)
118-
if err != nil {
119-
return errors.Wrap(err, "Could not create cache version file.")
120-
}
118+
return errors.Wrap(err, "Could not create cache version file.")
121119
}
122120
return nil
123-
124121
}
125122
return usererrors.New(errorNotACacheOrEmpty)
126123
}

0 commit comments

Comments
 (0)