format code with gofumpt
gofumpt (https://github.com/mvdan/gofumpt) provides a supserset of `gofmt` / `go fmt`, and addresses various formatting issues that linters may be checking for. We can consider enabling the `gofumpt` linter to verify the formatting in CI, although not every developer may have it installed, so for now this runs it once to get formatting in shape. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7f9f86c411
commit
e0281dc609
107 changed files with 404 additions and 483 deletions
|
@ -341,8 +341,8 @@ func (d *driver) Reader(ctx context.Context, path string, offset int64) (io.Read
|
|||
return file, err
|
||||
}
|
||||
|
||||
//if this is a DLO and it is clear that segments are still missing,
|
||||
//wait until they show up
|
||||
// if this is a DLO and it is clear that segments are still missing,
|
||||
// wait until they show up
|
||||
_, isDLO := headers["X-Object-Manifest"]
|
||||
size, err := file.Length()
|
||||
if err != nil {
|
||||
|
@ -357,7 +357,7 @@ func (d *driver) Reader(ctx context.Context, path string, offset int64) (io.Read
|
|||
continue
|
||||
}
|
||||
|
||||
//if not, then this reader will be fine
|
||||
// if not, then this reader will be fine
|
||||
return file, nil
|
||||
}
|
||||
}
|
||||
|
@ -436,9 +436,9 @@ func (d *driver) Stat(ctx context.Context, path string) (storagedriver.FileInfo,
|
|||
}
|
||||
}
|
||||
|
||||
//Don't trust an empty `objects` slice. A container listing can be
|
||||
//outdated. For files, we can make a HEAD request on the object which
|
||||
//reports existence (at least) much more reliably.
|
||||
// Don't trust an empty `objects` slice. A container listing can be
|
||||
// outdated. For files, we can make a HEAD request on the object which
|
||||
// reports existence (at least) much more reliably.
|
||||
waitingTime := readAfterWriteWait
|
||||
endTime := time.Now().Add(readAfterWriteTimeout)
|
||||
|
||||
|
@ -451,8 +451,8 @@ func (d *driver) Stat(ctx context.Context, path string) (storagedriver.FileInfo,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
//if this is a DLO and it is clear that segments are still missing,
|
||||
//wait until they show up
|
||||
// if this is a DLO and it is clear that segments are still missing,
|
||||
// wait until they show up
|
||||
_, isDLO := headers["X-Object-Manifest"]
|
||||
if isDLO && info.Bytes == 0 {
|
||||
if time.Now().Add(waitingTime).After(endTime) {
|
||||
|
@ -463,7 +463,7 @@ func (d *driver) Stat(ctx context.Context, path string) (storagedriver.FileInfo,
|
|||
continue
|
||||
}
|
||||
|
||||
//otherwise, accept the result
|
||||
// otherwise, accept the result
|
||||
fi.IsDir = false
|
||||
fi.Size = info.Bytes
|
||||
fi.ModTime = info.LastModified
|
||||
|
@ -681,7 +681,7 @@ func (d *driver) swiftSegmentPath(path string) (string, error) {
|
|||
}
|
||||
|
||||
func (d *driver) getAllSegments(path string) ([]swift.Object, error) {
|
||||
//a simple container listing works 99.9% of the time
|
||||
// a simple container listing works 99.9% of the time
|
||||
segments, err := d.Conn.ObjectsAll(d.Container, &swift.ObjectsOpts{Prefix: path})
|
||||
if err != nil {
|
||||
if err == swift.ContainerNotFound {
|
||||
|
@ -690,15 +690,15 @@ func (d *driver) getAllSegments(path string) ([]swift.Object, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
//build a lookup table by object name
|
||||
// build a lookup table by object name
|
||||
hasObjectName := make(map[string]struct{})
|
||||
for _, segment := range segments {
|
||||
hasObjectName[segment.Name] = struct{}{}
|
||||
}
|
||||
|
||||
//The container listing might be outdated (i.e. not contain all existing
|
||||
//segment objects yet) because of temporary inconsistency (Swift is only
|
||||
//eventually consistent!). Check its completeness.
|
||||
// The container listing might be outdated (i.e. not contain all existing
|
||||
// segment objects yet) because of temporary inconsistency (Swift is only
|
||||
// eventually consistent!). Check its completeness.
|
||||
segmentNumber := 0
|
||||
for {
|
||||
segmentNumber++
|
||||
|
@ -708,23 +708,23 @@ func (d *driver) getAllSegments(path string) ([]swift.Object, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
//This segment is missing in the container listing. Use a more reliable
|
||||
//request to check its existence. (HEAD requests on segments are
|
||||
//guaranteed to return the correct metadata, except for the pathological
|
||||
//case of an outage of large parts of the Swift cluster or its network,
|
||||
//since every segment is only written once.)
|
||||
// This segment is missing in the container listing. Use a more reliable
|
||||
// request to check its existence. (HEAD requests on segments are
|
||||
// guaranteed to return the correct metadata, except for the pathological
|
||||
// case of an outage of large parts of the Swift cluster or its network,
|
||||
// since every segment is only written once.)
|
||||
segment, _, err := d.Conn.Object(d.Container, segmentPath)
|
||||
switch err {
|
||||
case nil:
|
||||
//found new segment -> keep going, more might be missing
|
||||
// found new segment -> keep going, more might be missing
|
||||
segments = append(segments, segment)
|
||||
continue
|
||||
case swift.ObjectNotFound:
|
||||
//This segment is missing. Since we upload segments sequentially,
|
||||
//there won't be any more segments after it.
|
||||
// This segment is missing. Since we upload segments sequentially,
|
||||
// there won't be any more segments after it.
|
||||
return segments, nil
|
||||
default:
|
||||
return nil, err //unexpected error
|
||||
return nil, err // unexpected error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue