Skip to content

Commit

Permalink
Move db update logic outside of the downloadUrl loop
Browse files Browse the repository at this point in the history
  • Loading branch information
anatol committed May 19, 2023
1 parent f97696f commit 9189ae1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pacoloco.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,22 @@ func handleRequest(w http.ResponseWriter, req *http.Request) error {
for _, url := range repo.getUrls() {
served, err = downloadFileAndSend(url+path+"/"+fileName, filePath, ifLater, w)
if err == nil {
if config.Prefetch != nil && !strings.HasSuffix(fileName, ".sig") && !strings.HasSuffix(fileName, ".db") {
updateDBRequestedFile(repoName, fileName) // update info for prefetching
} else if err == nil && config.Prefetch != nil && strings.HasSuffix(fileName, ".db") {
updateDBRequestedDB(repoName, path, fileName)
}
break
}
}
}
if !served {
log.Printf("serving cached file %v", filePath)
http.ServeFile(w, req, filePath)
}

if config.Prefetch != nil && !strings.HasSuffix(fileName, ".sig") && !strings.HasSuffix(fileName, ".db") {
if config.Prefetch != nil && (err == nil || !served) {
if !strings.HasSuffix(fileName, ".sig") && !strings.HasSuffix(fileName, ".db") {
updateDBRequestedFile(repoName, fileName) // update info for prefetching
} else if strings.HasSuffix(fileName, ".db") {
updateDBRequestedDB(repoName, path, fileName)
}

}
return err
}
Expand Down

0 comments on commit 9189ae1

Please sign in to comment.