From 6da52d76a70bb8f69ced1d3b6ef260626e3ce03a Mon Sep 17 00:00:00 2001 From: nielash Date: Tue, 19 Dec 2023 12:00:37 -0500 Subject: [PATCH] fs: implement DirSetModTime optional feature --- fs/features.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/features.go b/fs/features.go index 060c4cc37..a6ec21e30 100644 --- a/fs/features.go +++ b/fs/features.go @@ -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