Merge pull request #3766 from thaJeztah/gofumpt

format code with gofumpt
This commit is contained in:
Hayley Swimelar 2022-11-04 12:19:53 +01:00 committed by GitHub
commit 52d948a9f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
107 changed files with 404 additions and 483 deletions

View file

@ -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
}
}
}