mirror of
https://github.com/rclone/rclone.git
synced 2024-11-24 17:34:57 +01:00
local: support setting custom --metadata during server-side Copy
This commit is contained in:
parent
87ec26001f
commit
f6d836eefd
@ -5,6 +5,7 @@ package local
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/go-darwin/apfs"
|
"github.com/go-darwin/apfs"
|
||||||
@ -30,9 +31,15 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
return nil, fs.ErrorCantCopy
|
return nil, fs.ErrorCantCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch metadata if --metadata is in use
|
||||||
|
meta, err := fs.GetMetadataOptions(ctx, f, src, fs.MetadataAsOpenOptions(ctx))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("copy: failed to read metadata: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Create destination
|
// Create destination
|
||||||
dstObj := f.newObject(remote)
|
dstObj := f.newObject(remote)
|
||||||
err := dstObj.mkdirAll()
|
err = dstObj.mkdirAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -42,6 +49,15 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fs.Debugf(remote, "server-side cloned!")
|
fs.Debugf(remote, "server-side cloned!")
|
||||||
|
|
||||||
|
// Set metadata if --metadata is in use
|
||||||
|
if meta != nil {
|
||||||
|
err = dstObj.writeMetadata(meta)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("copy: failed to set metadata: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return f.NewObject(ctx, remote)
|
return f.NewObject(ctx, remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user