Skip to content
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
30 changes: 18 additions & 12 deletions unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,27 @@ func Unpack(client *docker.Client, image string, dirname string, fatal bool) err

func prepareRootfs(dirname string, fatal bool) error {

err := os.Remove(dirname + SEPARATOR + ".dockerenv")
if err != nil {
if fatal == true {
return cli.NewExitError("could not remove docker env file", 86)
} else {
jww.WARN.Println(".dockerenv not found, extracting anyway")
_, err := os.Stat(dirname + SEPARATOR + ".dockerenv");
if err == nil {
err = os.Remove(dirname + SEPARATOR + ".dockerenv")
if err != nil {
if fatal == true {
return cli.NewExitError("could not remove docker env file", 86)
} else {
jww.WARN.Println("error on remove .dockerenv, extracting anyway")
}
}
}

err = os.Remove(dirname + SEPARATOR + ".dockerinit")
if err != nil {
if fatal == true {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for checking before removing, but i would still keep the fatal flag usage

return cli.NewExitError("could not remove docker init file", 86)
} else {
jww.WARN.Println(".dockerinit not found, extracting anyway")
_, err = os.Stat(dirname + SEPARATOR + ".dockerinit");
if err == nil {
err = os.Remove(dirname + SEPARATOR + ".dockerinit")
if err != nil {
if fatal == true {
return cli.NewExitError("could not remove docker init file", 86)
} else {
jww.WARN.Println("error on remove .dockerinit, extracting anyway")
}
}
}

Expand Down