-
Notifications
You must be signed in to change notification settings - Fork 950
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
bugfix: populate volume error #2087
bugfix: populate volume error #2087
Conversation
@@ -0,0 +1,120 @@ | |||
package archive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add unit-test for this package, thanks a lot!
pkg/archive/archive.go
Outdated
func tarFromDir(src string, writer io.Writer) error { | ||
// ensure the src actually exists before trying to tar it | ||
if _, err := os.Stat(src); err != nil { | ||
return fmt.Errorf("Unable to tar files - %v", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Errorf("failed to stat source file %s: %v", src, err)?
Codecov Report
@@ Coverage Diff @@
## master #2087 +/- ##
==========================================
- Coverage 65.35% 65.29% -0.07%
==========================================
Files 207 208 +1
Lines 16226 16292 +66
==========================================
+ Hits 10605 10638 +33
- Misses 4311 4330 +19
- Partials 1310 1324 +14
|
pkg/archive/archive.go
Outdated
|
||
// copy file data into tar writer | ||
if _, err := io.Copy(tw, f); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think before return err
, we need to close the file, since it is already open. Otherwise there will be fd leak.
pkg/archive/archive.go
Outdated
} | ||
|
||
if _, err := io.Copy(f, tr); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue.
I think before return err
, we need to close the file, since it is already open. Otherwise there will be fd leak.
166350f
to
74bc39b
Compare
I have update the codes, PTAL |
74bc39b
to
63e2be2
Compare
Signed-off-by: Eric Li <lcy041536@gmail.com>
63e2be2
to
c2186ef
Compare
LGTM |
Signed-off-by: Eric Li lcy041536@gmail.com
Ⅰ. Describe what this PR did
fix populate volume error
Ⅱ. Does this pull request fix one issue?
fixed #2084
Ⅲ. Describe how you did it
copy directory through tar and untar
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews