Skip to content

Commit

Permalink
Added quota info (total bytes and objects count) support for containers.
Browse files Browse the repository at this point in the history
Swift protocol allows to retrieve quota info for a container (https://docs.openstack.org/api-ref/object-store/#show-container-metadata). This commit allows to get those data (if available).
This is useful to enhance 'rclone about' command when used with some swift implementations such as Blomp storage.
  • Loading branch information
fsantagostinobietti authored and ncw committed Aug 28, 2024
1 parent b37a86b commit a27f2e5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,11 @@ func (c *Connection) ContainerNames(ctx context.Context, opts *ContainersOpts) (

// Container contains information about a container
type Container struct {
Name string // Name of the container
Count int64 // Number of objects in the container
Bytes int64 // Total number of bytes used in the container
Name string // Name of the container
Count int64 // Number of objects in the container
Bytes int64 // Total number of bytes used in the container
QuotaCount int64 // Maximum object count of the container. 0 if not available
QuotaBytes int64 // Maximum size of the container, in bytes. 0 if not available
}

// Containers returns a slice of structures with full information as
Expand Down Expand Up @@ -1350,6 +1352,9 @@ func (c *Connection) Container(ctx context.Context, container string) (info Cont
if info.Count, err = getInt64FromHeader(resp, "X-Container-Object-Count"); err != nil {
return
}
// optional headers
info.QuotaBytes, _ = getInt64FromHeader(resp, "X-Container-Meta-Quota-Bytes")
info.QuotaCount, _ = getInt64FromHeader(resp, "X-Container-Meta-Quota-Count")
return
}

Expand Down

0 comments on commit a27f2e5

Please sign in to comment.