diff --git a/internal/common/connection.go b/internal/common/connection.go index 20ed7342..95ba1dd5 100644 --- a/internal/common/connection.go +++ b/internal/common/connection.go @@ -793,7 +793,7 @@ func (c *BaseConnection) Rename(virtualSourcePath, virtualTargetPath string) err return c.renameInternal(virtualSourcePath, virtualTargetPath, false, vfs.CheckParentDir) } -func (c *BaseConnection) renameInternal(virtualSourcePath, virtualTargetPath string, +func (c *BaseConnection) renameInternal(virtualSourcePath, virtualTargetPath string, //nolint:gocyclo checkParentDestination bool, checks int, ) error { if virtualSourcePath == virtualTargetPath { @@ -816,7 +816,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 58bcb008..19726cca 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() { @@ -348,7 +351,7 @@ func (*eventRulesContainer) checkFsEventMatch(conditions *dataprovider.EventCond if len(conditions.Options.Protocols) > 0 && !slices.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 diff --git a/internal/vfs/fileinfo.go b/internal/vfs/fileinfo.go index dd0c153a..c27fbf79 100644 --- a/internal/vfs/fileinfo.go +++ b/internal/vfs/fileinfo.go @@ -105,6 +105,9 @@ func (fi *FileInfo) setMetadataFromPointerVal(value map[string]*string) { } func getMetadata(fi os.FileInfo) map[string]string { + if fi.Sys() == nil { + return nil + } if val, ok := fi.Sys().(map[string]string); ok { if len(val) > 0 { return val