local: implement Object.SetMetadata

This commit is contained in:
Nick Craig-Wood 2024-05-08 17:21:57 +01:00
parent cc634213a5
commit 629e895da8

View File

@ -1555,6 +1555,18 @@ func (o *Object) writeMetadata(metadata fs.Metadata) (err error) {
return err return err
} }
// SetMetadata sets metadata for an Object
//
// It should return fs.ErrorNotImplemented if it can't set metadata
func (o *Object) SetMetadata(ctx context.Context, metadata fs.Metadata) error {
err := o.writeMetadata(metadata)
if err != nil {
return fmt.Errorf("SetMetadata failed on Object: %w", err)
}
// Re-read info now we have finished setting stuff
return o.lstat()
}
func cleanRootPath(s string, noUNC bool, enc encoder.MultiEncoder) string { func cleanRootPath(s string, noUNC bool, enc encoder.MultiEncoder) string {
if runtime.GOOS != "windows" || !strings.HasPrefix(s, "\\") { if runtime.GOOS != "windows" || !strings.HasPrefix(s, "\\") {
if !filepath.IsAbs(s) { if !filepath.IsAbs(s) {
@ -1629,6 +1641,7 @@ var (
_ fs.MkdirMetadataer = &Fs{} _ fs.MkdirMetadataer = &Fs{}
_ fs.Object = &Object{} _ fs.Object = &Object{}
_ fs.Metadataer = &Object{} _ fs.Metadataer = &Object{}
_ fs.SetMetadataer = &Object{}
_ fs.Directory = &Directory{} _ fs.Directory = &Directory{}
_ fs.SetModTimer = &Directory{} _ fs.SetModTimer = &Directory{}
_ fs.SetMetadataer = &Directory{} _ fs.SetMetadataer = &Directory{}