Skip to content

Commit

Permalink
webdav: report full and consistent usage with about
Browse files Browse the repository at this point in the history
— allow either Used or Available to be ==0 (remote full or empty)
— compute Total if both values are received
  • Loading branch information
Yves G authored and ncw committed Mar 5, 2020
1 parent 747edf4 commit 5ee24f8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions backend/webdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,13 +989,14 @@ func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
return nil, errors.Wrap(err, "about call failed")
}
usage := &fs.Usage{}
if q.Available != 0 || q.Used != 0 {
if q.Available >= 0 && q.Used >= 0 {
usage.Total = fs.NewUsageValue(q.Available + q.Used)
}
if q.Used >= 0 {
usage.Used = fs.NewUsageValue(q.Used)
}
if q.Used >= 0 {
usage.Used = fs.NewUsageValue(q.Used)
}
if q.Available >= 0 {
usage.Free = fs.NewUsageValue(q.Available)
}
if q.Available >= 0 && q.Used >= 0 {
usage.Total = fs.NewUsageValue(q.Available + q.Used)
}
return usage, nil
}
Expand Down

0 comments on commit 5ee24f8

Please sign in to comment.