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