Files
rclone/backend/union/policy/mfs.go
Max Sum da9a44ea5e union: implement write on multiple remotes
Introduce policy from mergerfs.
2020-03-09 16:16:30 +00:00

32 lines
732 B
Go

package policy
import (
"context"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/backend/union/upstream"
)
func init(){
registerPolicy("mfs", &Mfs{})
}
// Mfs stands for most free space
// Of all the candidates on which the path exists choose the one with the most free space.
type Mfs struct {
EpMfs
}
// Create category policy, governing the creation of files and directories
func (p *Mfs) Create(ctx context.Context, upstreams []*upstream.Fs, path string) ([]*upstream.Fs, error) {
if len(upstreams) == 0 {
return nil, fs.ErrorObjectNotFound
}
upstreams = filterNC(upstreams)
if len(upstreams) == 0 {
return nil, fs.ErrorPermissionDenied
}
r, err := p.mfs(upstreams)
return []*upstream.Fs{r}, err
}