Merge 76cb21b7262e27b985ba34f65f799e6069526cb8 into 0b9671313b14ffe839ecbd7dd2ae5ac7f6f05db8

This commit is contained in:
Sofiane Benahmed 2025-04-15 20:32:10 +00:00 committed by GitHub
commit 2fbb66b585
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 0 deletions

View File

@ -148,6 +148,9 @@ func init() {
Name: "swift",
Description: "OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)",
NewFs: NewFs,
MetadataInfo: &fs.MetadataInfo{
Help: `User metadata is stored as X-Object-Meta- keys. swift metadata keys are case insensitive and are always returned in lower case.`,
},
Options: append([]fs.Option{{
Name: "env_auth",
Help: "Get swift credentials from environment variables in standard OpenStack form.",
@ -584,6 +587,7 @@ func NewFsWithConnection(ctx context.Context, opt *Options, name, root string, c
BucketBased: true,
BucketBasedRootOK: true,
SlowModTime: true,
ReadMetadata: true,
}).Fill(ctx, f)
if !f.opt.UseSegmentsContainer.Valid {
f.opt.UseSegmentsContainer.Value = !needFileSegmentsDirectory.MatchString(opt.Auth)
@ -1643,6 +1647,32 @@ func (o *Object) MimeType(ctx context.Context) string {
return o.contentType
}
// Metadata returns metadata for an object
//
// It should return nil if there is no Metadata
func (o *Object) Metadata(ctx context.Context) (fs.Metadata, error) {
err := o.readMetaData(ctx) // reads info and headers, returning an error
if err != nil {
return nil, err
}
objectMetadata := o.headers.ObjectMetadata()
if len(objectMetadata) == 0 {
return nil, nil
}
metadata := make(fs.Metadata, len(objectMetadata))
for k, v := range objectMetadata {
switch k {
case "mtime":
if modTime, err := swift.FloatStringToTime(v); err == nil {
metadata["mtime"] = modTime.Format(time.RFC3339Nano)
}
default:
metadata[k] = v
}
}
return metadata, nil
}
// Check the interfaces are satisfied
var (
_ fs.Fs = &Fs{}
@ -1652,4 +1682,5 @@ var (
_ fs.ListRer = &Fs{}
_ fs.Object = &Object{}
_ fs.MimeTyper = &Object{}
_ fs.Metadataer = &Object{}
)

View File

@ -139,6 +139,12 @@ excess files in the container.
rclone sync --interactive /home/local/directory remote:container
Sync a remote container to a bucket and maintain object metadata:
rclone sync --metadata remote:container s3:bucket
Note that swift backend only support reading metadata, not writing to it.
### Configuration from an OpenStack credentials file
An OpenStack credentials file typically looks something something