Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added quota info (total bytes and objects count) support for containers. #186

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"fmt"
"hash"
"io"
"io/ioutil"

Check failure on line 15 in swift.go

View workflow job for this annotation

GitHub Actions / go1.20

SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
"mime"
"net/http"
"net/url"
Expand Down Expand Up @@ -920,9 +920,11 @@

// 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 @@
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
Loading