mirror of
https://github.com/rclone/rclone.git
synced 2025-01-31 10:41:42 +01:00
union: make quota relevant policies resilient to unsupported fields
This commit is contained in:
parent
67b38a457b
commit
c4545465e7
@ -24,7 +24,8 @@ func (p *EpLfs) lfs(upstreams []*upstream.Fs) (*upstream.Fs, error) {
|
||||
for _, u := range upstreams {
|
||||
space, err := u.GetFreeSpace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fs.LogPrintf(fs.LogLevelNotice, nil,
|
||||
"Free Space is not supported for upstream %s, treating as infinite", u.Name())
|
||||
}
|
||||
if space < minFreeSpace {
|
||||
minFreeSpace = space
|
||||
@ -43,7 +44,8 @@ func (p *EpLfs) lfsEntries(entries []upstream.Entry) (upstream.Entry, error) {
|
||||
for _, e := range entries {
|
||||
space, err := e.UpstreamFs().GetFreeSpace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fs.LogPrintf(fs.LogLevelNotice, nil,
|
||||
"Free Space is not supported for upstream %s, treating as infinite", e.UpstreamFs().Name())
|
||||
}
|
||||
if space < minFreeSpace {
|
||||
minFreeSpace = space
|
||||
|
@ -24,7 +24,8 @@ func (p *EpLus) lus(upstreams []*upstream.Fs) (*upstream.Fs, error) {
|
||||
for _, u := range upstreams {
|
||||
space, err := u.GetUsedSpace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fs.LogPrintf(fs.LogLevelNotice, nil,
|
||||
"Used Space is not supported for upstream %s, treating as 0", u.Name())
|
||||
}
|
||||
if space < minUsedSpace {
|
||||
minUsedSpace = space
|
||||
@ -43,7 +44,8 @@ func (p *EpLus) lusEntries(entries []upstream.Entry) (upstream.Entry, error) {
|
||||
for _, e := range entries {
|
||||
space, err := e.UpstreamFs().GetFreeSpace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fs.LogPrintf(fs.LogLevelNotice, nil,
|
||||
"Used Space is not supported for upstream %s, treating as 0", e.UpstreamFs().Name())
|
||||
}
|
||||
if space < minUsedSpace {
|
||||
minUsedSpace = space
|
||||
|
@ -23,7 +23,8 @@ func (p *EpMfs) mfs(upstreams []*upstream.Fs) (*upstream.Fs, error) {
|
||||
for _, u := range upstreams {
|
||||
space, err := u.GetFreeSpace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fs.LogPrintf(fs.LogLevelNotice, nil,
|
||||
"Free Space is not supported for upstream %s, treating as infinite", u.Name())
|
||||
}
|
||||
if maxFreeSpace < space {
|
||||
maxFreeSpace = space
|
||||
@ -42,7 +43,8 @@ func (p *EpMfs) mfsEntries(entries []upstream.Entry) (upstream.Entry, error) {
|
||||
for _, e := range entries {
|
||||
space, err := e.UpstreamFs().GetFreeSpace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
fs.LogPrintf(fs.LogLevelNotice, nil,
|
||||
"Free Space is not supported for upstream %s, treating as infinite", e.UpstreamFs().Name())
|
||||
}
|
||||
if maxFreeSpace < space {
|
||||
maxFreeSpace = space
|
||||
|
@ -3,6 +3,7 @@ package upstream
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"math"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -254,13 +255,13 @@ func (f *Fs) GetFreeSpace() (int64, error) {
|
||||
if atomic.LoadInt64(&f.cacheExpiry) <= time.Now().Unix() {
|
||||
err := f.updateUsage()
|
||||
if err != nil {
|
||||
return 0, ErrUsageFieldNotSupported
|
||||
return math.MaxInt64, ErrUsageFieldNotSupported
|
||||
}
|
||||
}
|
||||
f.cacheMutex.RLock()
|
||||
defer f.cacheMutex.RUnlock()
|
||||
if f.usage.Free == nil {
|
||||
return 0, ErrUsageFieldNotSupported
|
||||
return math.MaxInt64, ErrUsageFieldNotSupported
|
||||
}
|
||||
return *f.usage.Free, nil
|
||||
}
|
||||
|
@ -49,6 +49,18 @@ A path preserving policy will only consider upstreams where the relative path be
|
||||
|
||||
When using non-path preserving policies paths will be created in target upstreams as necessary.
|
||||
|
||||
#### Quota Relevant Policies
|
||||
|
||||
Some policies rely on quota information. These policies should be used only if your upstreams support the respective quota fields.
|
||||
|
||||
| Policy | Required Field |
|
||||
|------------|----------------|
|
||||
| lfs, eplfs | Free |
|
||||
| mfs, epmfs | Free |
|
||||
| lus, eplus | Used |
|
||||
|
||||
To check if your upstream support the field, run `rclone about remote: [flags]` and see if the reuqired field exists.
|
||||
|
||||
#### Filters
|
||||
|
||||
Policies basically search upstream remotes and create a list of files / paths for functions to work on. The policy is responsible for filtering and sorting. The policy type defines the sorting but filtering is mostly uniform as described below.
|
||||
|
Loading…
Reference in New Issue
Block a user