Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

sftp: implement DirSetModTime

nielash17c0ecc72cd9
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index 4508d780b..68f9467c1 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -1367,6 +1367,15 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error {
return f.mkdir(ctx, root)
}
+// DirSetModTime sets the directory modtime for dir
+func (f *Fs) DirSetModTime(ctx context.Context, dir string, modTime time.Time) error {
+ o := Object{
+ fs: f,
+ remote: dir,
+ }
+ return o.SetModTime(ctx, modTime)
+}
+
// Rmdir removes the root directory of the Fs object
func (f *Fs) Rmdir(ctx context.Context, dir string) error {
// Check to see if directory is empty as some servers will
@@ -1985,7 +1994,7 @@ func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error {
return fmt.Errorf("SetModTime failed: %w", err)
}
err = o.stat(ctx)
- if err != nil {
+ if err != nil && err != fs.ErrorIsDir {
return fmt.Errorf("SetModTime stat failed: %w", err)
}
return nil
@@ -2179,12 +2188,13 @@ func (o *Object) Remove(ctx context.Context) error {
// Check the interfaces are satisfied
var (
- _ fs.Fs = &Fs{}
- _ fs.PutStreamer = &Fs{}
- _ fs.Mover = &Fs{}
- _ fs.Copier = &Fs{}
- _ fs.DirMover = &Fs{}
- _ fs.Abouter = &Fs{}
- _ fs.Shutdowner = &Fs{}
- _ fs.Object = &Object{}
+ _ fs.Fs = &Fs{}
+ _ fs.PutStreamer = &Fs{}
+ _ fs.Mover = &Fs{}
+ _ fs.Copier = &Fs{}
+ _ fs.DirMover = &Fs{}
+ _ fs.DirSetModTimer = &Fs{}
+ _ fs.Abouter = &Fs{}
+ _ fs.Shutdowner = &Fs{}
+ _ fs.Object = &Object{}
)
diff --git a/docs/content/overview.md b/docs/content/overview.md
index 33792640e..6258ba320 100644
--- a/docs/content/overview.md
+++ b/docs/content/overview.md
@@ -52,7 +52,7 @@ Here is an overview of the major features of each cloud storage system.
| QingStor | MD5 | - ⁹ | No | No | R/W | - |
| Quatrix by Maytech | - | R/W | No | No | - | - |
| Seafile | - | - | No | No | - | - |
-| SFTP | MD5, SHA1 ² | R/W | Depends | No | - | - |
+| SFTP | MD5, SHA1 ² | DR/W | Depends | No | - | - |
| Sia | - | - | No | No | - | - |
| SMB | - | R/W | Yes | No | - | - |
| SugarSync | - | - | No | No | - | - |