webdav: report full and consistent usage with about

— allow either Used or Available to be ==0 (remote full or empty)
— compute Total if both values are received
This commit is contained in:
Yves G 2020-03-01 14:41:48 +01:00 committed by Nick Craig-Wood
parent 747edf42c1
commit 5ee24f804f

View File

@ -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.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
}