diff --git a/internal/common/connection.go b/internal/common/connection.go index db04ab67..d3b613c0 100644 --- a/internal/common/connection.go +++ b/internal/common/connection.go @@ -792,7 +792,7 @@ func (c *BaseConnection) Rename(virtualSourcePath, virtualTargetPath string) err return c.renameInternal(virtualSourcePath, virtualTargetPath, false) } -func (c *BaseConnection) renameInternal(virtualSourcePath, virtualTargetPath string, checkParentDestination bool) error { +func (c *BaseConnection) renameInternal(virtualSourcePath, virtualTargetPath string, checkParentDestination bool) error { //nolint:gocyclo if virtualSourcePath == virtualTargetPath { return fmt.Errorf("the rename source and target cannot be the same: %w", c.GetOpUnsupportedError()) } @@ -813,7 +813,11 @@ func (c *BaseConnection) renameInternal(virtualSourcePath, virtualTargetPath str return c.GetPermissionDeniedError() } initialSize := int64(-1) - if dstInfo, err := fsDst.Lstat(fsTargetPath); err == nil { + dstInfo, err := fsDst.Lstat(fsTargetPath) + if err != nil && !fsDst.IsNotExist(err) { + return err + } + if err == nil { checkParentDestination = false if dstInfo.IsDir() { c.Log(logger.LevelWarn, "attempted to rename %q overwriting an existing directory %q", diff --git a/internal/common/eventmanager.go b/internal/common/eventmanager.go index fcb517ee..d67f171e 100644 --- a/internal/common/eventmanager.go +++ b/internal/common/eventmanager.go @@ -71,6 +71,9 @@ var ( // eventManager handle the supported event rules actions eventManager eventRulesContainer multipartQuoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") + fsEventsWithSize = []string{operationPreDelete, OperationPreUpload, operationDelete, + operationCopy, operationDownload, operationFirstUpload, operationFirstDownload, + operationUpload} ) func init() { @@ -347,7 +350,7 @@ func (*eventRulesContainer) checkFsEventMatch(conditions *dataprovider.EventCond if len(conditions.Options.Protocols) > 0 && !util.Contains(conditions.Options.Protocols, params.Protocol) { return false } - if params.Event == operationUpload || params.Event == operationDownload { + if slices.Contains(fsEventsWithSize, params.Event) { if conditions.Options.MinFileSize > 0 { if params.FileSize < conditions.Options.MinFileSize { return false