Allow item status 425 "too early" for items when changing metadata

Fixes the upload behavior with ownCloud Infinite Scale
This commit is contained in:
Klaas Freitag 2024-10-17 15:19:06 +02:00
parent f1b4188b60
commit e1ea2fa6b8
2 changed files with 23 additions and 11 deletions

View file

@ -82,26 +82,37 @@ type Prop struct {
// Parse a status of the form "HTTP/1.1 200 OK" or "HTTP/1.1 200" // Parse a status of the form "HTTP/1.1 200 OK" or "HTTP/1.1 200"
var parseStatus = regexp.MustCompile(`^HTTP/[0-9.]+\s+(\d+)`) var parseStatus = regexp.MustCompile(`^HTTP/[0-9.]+\s+(\d+)`)
// StatusOK examines the Status and returns an OK flag // Code extracts the status code from the first status
func (p *Prop) StatusOK() bool { func (p *Prop) Code() int {
// Assume OK if no statuses received
if len(p.Status) == 0 { if len(p.Status) == 0 {
return true return -1
} }
match := parseStatus.FindStringSubmatch(p.Status[0]) match := parseStatus.FindStringSubmatch(p.Status[0])
if len(match) < 2 { if len(match) < 2 {
return false return 0
} }
code, err := strconv.Atoi(match[1]) code, err := strconv.Atoi(match[1])
if err != nil { if err != nil {
return 0
}
return code
}
// StatusOK examines the Status and returns an OK flag
func (p *Prop) StatusOK() bool {
// Fetch status code as int
c := p.Code()
// Assume OK if no statuses received
if c == -1 {
return true
}
if c == 0 {
return false return false
} }
// allow status 425 "too early" for files still in postprocessing if c >= 200 && c < 300 {
if code == 425 {
return true
}
if code >= 200 && code < 300 {
return true return true
} }
return false return false
} }

View file

@ -356,7 +356,8 @@ func (f *Fs) readMetaDataForPath(ctx context.Context, path string, depth string)
return nil, fs.ErrorObjectNotFound return nil, fs.ErrorObjectNotFound
} }
item := result.Responses[0] item := result.Responses[0]
if !item.Props.StatusOK() { // status code 425 is accepted here as well
if !(item.Props.StatusOK() || item.Props.Code() == 425) {
return nil, fs.ErrorObjectNotFound return nil, fs.ErrorObjectNotFound
} }
if itemIsDir(&item) { if itemIsDir(&item) {