github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/backend/union/policy/lfs.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("lfs", &Lfs{}) 12 } 13 14 // Lfs stands for least free space 15 // Search category: same as eplfs. 16 // Action category: same as eplfs. 17 // Create category: Pick the drive with the least free space. 18 type Lfs struct { 19 EpLfs 20 } 21 22 // Create category policy, governing the creation of files and directories 23 func (p *Lfs) 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 nil, fs.ErrorPermissionDenied 30 } 31 u, err := p.lfs(upstreams) 32 return []*upstream.Fs{u}, err 33 }