Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
fix newest-file selection for offline cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Strum355 committed Mar 1, 2024
1 parent 7ea5a30 commit 41d030c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/apk/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,15 @@ func (t *cacheTransport) RoundTrip(request *http.Request) (*http.Response, error
return nil, err
}

if fi.ModTime().After(newest.ModTime()) {
if (fi.ModTime().After(newest.ModTime()) || newest.IsDir()) && !fi.IsDir() {
newest = fi
}
}

if newest.IsDir() {
return nil, fmt.Errorf("%s is a directory", newest.Name())
}

f, err := os.Open(filepath.Join(cacheDir, newest.Name()))
if err != nil {
return nil, err
Expand Down

0 comments on commit 41d030c

Please sign in to comment.