mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
fs: implement optional Metadata interface for Objects #111
This implements integration tests for the feature also.
This commit is contained in:
29
fs/metadata.go
Normal file
29
fs/metadata.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package fs
|
||||
|
||||
import "context"
|
||||
|
||||
// Metadata represents Object metadata in a standardised form
|
||||
//
|
||||
// See docs/content/metadata.md for the interpretation of the keys
|
||||
type Metadata map[string]string
|
||||
|
||||
// Set k to v on m
|
||||
//
|
||||
// If m is nil, then it will get made
|
||||
func (m *Metadata) Set(k, v string) {
|
||||
if *m == nil {
|
||||
*m = make(Metadata, 1)
|
||||
}
|
||||
(*m)[k] = v
|
||||
}
|
||||
|
||||
// GetMetadata from an ObjectInfo
|
||||
//
|
||||
// If the object has no metadata then metadata will be nil
|
||||
func GetMetadata(ctx context.Context, o ObjectInfo) (metadata Metadata, err error) {
|
||||
do, ok := o.(Metadataer)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return do.Metadata(ctx)
|
||||
}
|
||||
Reference in New Issue
Block a user