daemon: Daemon.ContainerStatPath, ContainerArchivePath: minor refactor

- remove named error-returns
- make error-handling slightly more idiomatic (check for non-nil errors)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-12-28 13:19:57 +01:00
parent 190ad0610d
commit 2145cf6309
3 changed files with 19 additions and 19 deletions

View File

@@ -20,7 +20,7 @@ import (
// containerStatPath stats the filesystem resource at the specified path in this
// container. Returns stat info about the resource.
func (daemon *Daemon) containerStatPath(container *container.Container, path string) (stat *containertypes.PathStat, err error) {
func (daemon *Daemon) containerStatPath(container *container.Container, path string) (*containertypes.PathStat, error) {
container.Lock()
defer container.Unlock()
@@ -36,11 +36,11 @@ func (daemon *Daemon) containerStatPath(container *container.Container, path str
// containerArchivePath creates an archive of the filesystem resource at the specified
// path in this container. Returns a tar archive of the resource and stat info
// about the resource.
func (daemon *Daemon) containerArchivePath(container *container.Container, path string) (content io.ReadCloser, stat *containertypes.PathStat, err error) {
func (daemon *Daemon) containerArchivePath(container *container.Container, path string) (content io.ReadCloser, stat *containertypes.PathStat, retErr error) {
container.Lock()
defer func() {
if err != nil {
if retErr != nil {
// Wait to unlock the container until the archive is fully read
// (see the ReadCloseWrapper func below) or if there is an error
// before that occurs.
@@ -54,8 +54,8 @@ func (daemon *Daemon) containerArchivePath(container *container.Container, path
}
defer func() {
if err != nil {
cfs.Close()
if retErr != nil {
_ = cfs.Close()
}
}()