fix (zip): handle offline edge case

This commit is contained in:
MickaelK
2025-08-04 23:26:38 +10:00
parent 149d1f3630
commit cc031163d9
2 changed files with 11 additions and 7 deletions

View File

@ -783,19 +783,21 @@ func FileDownloader(ctx *App, res http.ResponseWriter, req *http.Request) {
if strings.HasSuffix(backendPath, "/") == false {
// Process File
zipPath := strings.TrimPrefix(backendPath, zipRoot)
file, err := ctx.Backend.Cat(backendPath)
if err != nil {
*errList = append(*errList, fmt.Sprintf("downloader::cat %s %s\n", zipPath, err.Error()))
if err == ErrNotReachable {
return nil
}
Log.Debug("downloader::cat backendPath['%s'] zipPath['%s'] error['%s']", backendPath, zipPath, err.Error())
return err
}
zipFile, err := zw.Create(zipPath)
if err != nil {
*errList = append(*errList, fmt.Sprintf("downloader::create %s %s\n", zipPath, err.Error()))
Log.Debug("downloader::create backendPath['%s'] zipPath['%s'] error['%s']", backendPath, zipPath, err.Error())
return err
}
file, err := ctx.Backend.Cat(backendPath)
if err != nil {
*errList = append(*errList, fmt.Sprintf("downloader::cat %s %s\n", zipPath, err.Error()))
Log.Debug("downloader::cat backendPath['%s'] zipPath['%s'] error['%s']", backendPath, zipPath, err.Error())
io.Copy(zipFile, strings.NewReader(""))
return err
}
if _, err = io.Copy(zipFile, file); err != nil {
*errList = append(*errList, fmt.Sprintf("downloader::copy %s %s\n", zipPath, err.Error()))
Log.Debug("downloader::copy backendPath['%s'] zipPath['%s'] error['%s']", backendPath, zipPath, err.Error())