Add MergeDirs optional interface and implement it for drive

This commit is contained in:
Nick Craig-Wood 2017-08-02 16:51:24 +01:00
parent 81a2ab599f
commit db1995e63a
3 changed files with 109 additions and 12 deletions

View file

@ -318,6 +318,10 @@ type Features struct {
// nil and the error
PutStream func(in io.Reader, src ObjectInfo, options ...OpenOption) (Object, error)
// MergeDirs merges the contents of all the directories passed
// in into the first one and rmdirs the other directories.
MergeDirs func([]Directory) error
// CleanUp the trash in the Fs
//
// Implement this if you have a way of emptying the trash or
@ -374,6 +378,9 @@ func (ft *Features) Fill(f Fs) *Features {
if do, ok := f.(PutStreamer); ok {
ft.PutStream = do.PutStream
}
if do, ok := f.(MergeDirser); ok {
ft.MergeDirs = do.MergeDirs
}
if do, ok := f.(CleanUpper); ok {
ft.CleanUp = do.CleanUp
}
@ -422,6 +429,9 @@ func (ft *Features) Mask(f Fs) *Features {
if mask.PutStream == nil {
ft.PutStream = nil
}
if mask.MergeDirs == nil {
ft.MergeDirs = nil
}
if mask.CleanUp == nil {
ft.CleanUp = nil
}
@ -538,6 +548,13 @@ type PutStreamer interface {
PutStream(in io.Reader, src ObjectInfo, options ...OpenOption) (Object, error)
}
// MergeDirser is an option interface for Fs
type MergeDirser interface {
// MergeDirs merges the contents of all the directories passed
// in into the first one and rmdirs the other directories.
MergeDirs([]Directory) error
}
// CleanUpper is an optional interfaces for Fs
type CleanUpper interface {
// CleanUp the trash in the Fs