github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/backend/union/policy/ff.go (about) 1 package policy 2 3 import ( 4 "context" 5 6 "github.com/rclone/rclone/backend/union/upstream" 7 "github.com/rclone/rclone/fs" 8 ) 9 10 func init() { 11 registerPolicy("ff", &FF{}) 12 } 13 14 // FF stands for first found 15 // Search category: same as epff. 16 // Action category: same as epff. 17 // Create category: Given the order of the candidates, act on the first one found. 18 type FF struct { 19 EpFF 20 } 21 22 // Create category policy, governing the creation of files and directories 23 func (p *FF) Create(ctx context.Context, upstreams []*upstream.Fs, path string) ([]*upstream.Fs, error) { 24 if len(upstreams) == 0 { 25 return nil, fs.ErrorObjectNotFound 26 } 27 upstreams = filterNC(upstreams) 28 if len(upstreams) == 0 { 29 return upstreams, fs.ErrorPermissionDenied 30 } 31 return upstreams[:1], nil 32 }