mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
union: Implement multiple writable remotes
This commit is contained in:
33
backend/union/policy/lfs.go
Normal file
33
backend/union/policy/lfs.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rclone/rclone/backend/union/upstream"
|
||||
"github.com/rclone/rclone/fs"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registerPolicy("lfs", &Lfs{})
|
||||
}
|
||||
|
||||
// Lfs stands for least free space
|
||||
// Search category: same as eplfs.
|
||||
// Action category: same as eplfs.
|
||||
// Create category: Pick the drive with the least free space.
|
||||
type Lfs struct {
|
||||
EpLfs
|
||||
}
|
||||
|
||||
// Create category policy, governing the creation of files and directories
|
||||
func (p *Lfs) 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
|
||||
}
|
||||
u, err := p.lfs(upstreams)
|
||||
return []*upstream.Fs{u}, err
|
||||
}
|
||||
Reference in New Issue
Block a user