fs: implement DirSetModTime optional feature

This commit is contained in:
nielash 2023-12-19 12:00:37 -05:00 committed by Nick Craig-Wood
parent 71a1bbb2be
commit 6da52d76a7

View File

@ -117,6 +117,9 @@ type Features struct {
// in into the first one and rmdirs the other directories.
MergeDirs func(ctx context.Context, dirs []Directory) error
// DirSetModTime sets the metadata on the directory to set the modification date
DirSetModTime func(ctx context.Context, dir string, modTime time.Time) error
// CleanUp the trash in the Fs
//
// Implement this if you have a way of emptying the trash or
@ -297,6 +300,9 @@ func (ft *Features) Fill(ctx context.Context, f Fs) *Features {
if do, ok := f.(MergeDirser); ok {
ft.MergeDirs = do.MergeDirs
}
if do, ok := f.(DirSetModTimer); ok {
ft.DirSetModTime = do.DirSetModTime
}
if do, ok := f.(CleanUpper); ok {
ft.CleanUp = do.CleanUp
}
@ -392,6 +398,9 @@ func (ft *Features) Mask(ctx context.Context, f Fs) *Features {
if mask.MergeDirs == nil {
ft.MergeDirs = nil
}
if mask.DirSetModTime == nil {
ft.DirSetModTime = nil
}
if mask.CleanUp == nil {
ft.CleanUp = nil
}
@ -578,6 +587,12 @@ type MergeDirser interface {
MergeDirs(ctx context.Context, dirs []Directory) error
}
// DirSetModTimer is an optional interface for Fs
type DirSetModTimer interface {
// DirSetModTime sets the metadata on the directory to set the modification date
DirSetModTime(ctx context.Context, dir string, modTime time.Time) error
}
// CleanUpper is an optional interfaces for Fs
type CleanUpper interface {
// CleanUp the trash in the Fs