From 6e85a39e9997189d1b828b49a2dc8049c67ad138 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 5 Mar 2024 17:21:06 +0000 Subject: [PATCH] local: support metadata setting and mapping on server side Move Before this change the backend would not run the metadata mapper and it would ignore metadata set when doing server side moves. --- backend/local/local.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/local/local.go b/backend/local/local.go index a260a2255..848375901 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -832,6 +832,12 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, return nil, err } + // Fetch metadata if --metadata is in use + meta, err := fs.GetMetadataOptions(ctx, f, src, fs.MetadataAsOpenOptions(ctx)) + if err != nil { + return nil, fmt.Errorf("move: failed to read metadata: %w", err) + } + // Do the move err = os.Rename(srcObj.path, dstObj.path) if os.IsNotExist(err) { @@ -847,6 +853,12 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, return nil, fs.ErrorCantMove } + // Set metadata if --metadata is in use + err = dstObj.writeMetadata(meta) + if err != nil { + return nil, fmt.Errorf("move: failed to set metadata: %w", err) + } + // Update the info err = dstObj.lstat() if err != nil {