Skip to content

Commit a27f2e5

Browse files
fsantagostinobiettincw
authored andcommitted
Added quota info (total bytes and objects count) support for containers.
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.
1 parent b37a86b commit a27f2e5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

swift.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,11 @@ func (c *Connection) ContainerNames(ctx context.Context, opts *ContainersOpts) (
920920

921921
// Container contains information about a container
922922
type Container struct {
923-
Name string // Name of the container
924-
Count int64 // Number of objects in the container
925-
Bytes int64 // Total number of bytes used in the container
923+
Name string // Name of the container
924+
Count int64 // Number of objects in the container
925+
Bytes int64 // Total number of bytes used in the container
926+
QuotaCount int64 // Maximum object count of the container. 0 if not available
927+
QuotaBytes int64 // Maximum size of the container, in bytes. 0 if not available
926928
}
927929

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

0 commit comments

Comments
 (0)