Skip to content

Commit f37130a

Browse files
committed
Enable fallback to .tar file cache
1 parent 7ffd128 commit f37130a

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

pkg/leeway/cache.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,31 @@ func (fsc *FilesystemCache) Location(pkg *Package) (path string, exists bool) {
5757
return "", false
5858
}
5959

60-
fn := filepath.Join(fsc.Origin, fmt.Sprintf("%s.tar.gz", version))
61-
if _, err := os.Stat(fn); os.IsNotExist(err) {
62-
return fn, false
60+
// Check for .tar.gz file first
61+
gzPath := filepath.Join(fsc.Origin, fmt.Sprintf("%s.tar.gz", version))
62+
if fileExists(gzPath) {
63+
return gzPath, true
6364
}
6465

65-
return fn, true
66+
// Fall back to .tar file
67+
tarPath := filepath.Join(fsc.Origin, fmt.Sprintf("%s.tar", version))
68+
exists = fileExists(tarPath)
69+
70+
return tarPath, exists
71+
}
72+
73+
// fileExists checks if a file exists and is not a directory
74+
func fileExists(filename string) bool {
75+
info, err := os.Stat(filename)
76+
if err != nil {
77+
if os.IsNotExist(err) {
78+
return false
79+
}
80+
81+
return false
82+
}
83+
84+
return !info.IsDir()
6685
}
6786

6887
// RemoteCache can download and upload build artifacts into a local cache

0 commit comments

Comments
 (0)