event action: add update modtime to fs rename

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-08-09 20:18:33 +02:00
parent a5c5e85144
commit 81433e00d1
30 changed files with 383 additions and 182 deletions

View File

@@ -176,7 +176,7 @@ func (fs *OsFs) Create(name string, flag, _ int) (File, PipeWriter, func(), erro
}
// Rename renames (moves) source to target
func (fs *OsFs) Rename(source, target string) (int, int64, error) {
func (fs *OsFs) Rename(source, target string, checks int) (int, int64, error) {
if source == target {
return -1, -1, nil
}
@@ -199,9 +199,15 @@ func (fs *OsFs) Rename(source, target string) (int, int64, error) {
fsLog(fs, logger.LevelError, "cross device copy error: %v", err)
return -1, -1, err
}
if checks&CheckUpdateModTime != 0 {
fs.Chtimes(target, time.Now(), time.Now(), false) //nolint:errcheck
}
err = os.RemoveAll(source)
return -1, -1, err
}
if checks&CheckUpdateModTime != 0 && err == nil {
fs.Chtimes(target, time.Now(), time.Now(), false) //nolint:errcheck
}
return -1, -1, err
}