32 lines
748 B
Go
32 lines
748 B
Go
package ai_summarizer
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/minio/minio-go/v7"
|
|
)
|
|
|
|
// isMinioNotFound reports whether err indicates the object or bucket key is missing.
|
|
// The MinIO Go SDK often returns success from GetObject and surfaces NoSuchKey on Read.
|
|
func isMinioNotFound(err error) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
var minioErr minio.ErrorResponse
|
|
if errors.As(err, &minioErr) {
|
|
if minioErr.StatusCode == http.StatusNotFound {
|
|
return true
|
|
}
|
|
switch strings.ToLower(minioErr.Code) {
|
|
case "nosuchkey", "notfound":
|
|
return true
|
|
}
|
|
}
|
|
msg := strings.ToLower(err.Error())
|
|
return strings.Contains(msg, "does not exist") ||
|
|
strings.Contains(msg, "nosuchkey") ||
|
|
strings.Contains(msg, "not found")
|
|
}
|