wip: port FileDownload

This commit is contained in:
Michael Hohn
2024-05-20 14:27:50 -07:00
committed by =Michael Hohn
parent ccf064fe6c
commit cf595f338a
2 changed files with 42 additions and 3 deletions

View File

@@ -195,3 +195,18 @@ func GetStatus(sessionid int, orl co.OwnerRepo) co.Status {
defer mutex.Unlock()
return status[co.JobSpec{ID: sessionid, OwnerRepo: orl}]
}
func ResultAsFile(path string) (string, []byte, error) {
fpath := path
if !filepath.IsAbs(path) {
fpath = "/" + path
}
file, err := os.ReadFile(fpath)
if err != nil {
slog.Warn("Failed to read results file", fpath, err)
return "", nil, err
}
return fpath, file, nil
}