Skip to content

Commit

Permalink
Strip trailing slashes when squashing images
Browse files Browse the repository at this point in the history
  • Loading branch information
iaguis committed Jan 29, 2015
1 parent 0cb48b8 commit c9666e6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/docker2aci.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,10 @@ func reduceACIs(squashAcc *SquashAcc, currentPath string) (*SquashAcc, error) {
continue
}

if !in(squashAcc.Filelist, hdr.Name) {
squashAcc.Filelist = append(squashAcc.Filelist, hdr.Name)
sanitizedName := stripTrailingSlashes(hdr.Name)

if !in(squashAcc.Filelist, sanitizedName) {
squashAcc.Filelist = append(squashAcc.Filelist, sanitizedName)

if err := squashAcc.OutWriter.WriteHeader(hdr); err != nil {
return nil, fmt.Errorf("Error writing header: %v", err)
Expand All @@ -639,6 +641,14 @@ func reduceACIs(squashAcc *SquashAcc, currentPath string) (*SquashAcc, error) {
return squashAcc, nil
}

func stripTrailingSlashes(str string) string {
for len(str) > 0 && str[len(str)-1] == '/' {
str = str[0 : len(str)-1]
}

return str
}

func getFileInTar(fileName string, tarFile *os.File) (*tar.Header, *bytes.Buffer, error) {
defer func() {
tarFile.Seek(0, 0)
Expand Down

0 comments on commit c9666e6

Please sign in to comment.