Skip to content

Commit

Permalink
Bugfix: unzip an archive uploaded with "Archive" and "IncludeDirs" pa…
Browse files Browse the repository at this point in the history
…rameters doesn't work (#440)
  • Loading branch information
gailazar300 authored Oct 13, 2021
1 parent f8b551b commit f00dfff
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions artifactory/services/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,13 @@ func (us *UploadService) addFileToZip(artifact *clientutils.Artifact, progressPr
header.Name = clientutils.TrimPath(localPath)
}
header.Method = zip.Deflate

// If this is a directory, add it to the writer with a trailing slash.
if info.IsDir() {
header.Name += "/"
_, e = zipWriter.CreateHeader(header)
return
}
writer, e := zipWriter.CreateHeader(header)
if errorutils.CheckError(e) != nil {
return
Expand All @@ -775,12 +782,6 @@ func (us *UploadService) addFileToZip(artifact *clientutils.Artifact, progressPr
_, e = writer.Write([]byte(filepath.ToSlash(artifact.SymlinkTargetPath)))
return
}
// If this is a directory, add it to the writer with a trailing slash.
if info.IsDir() {
_, e = writer.Write([]byte(filepath.ToSlash(localPath + fileutils.GetFileSeparator())))
return
}

file, e := os.Open(localPath)
if e != nil {
return e
Expand Down

0 comments on commit f00dfff

Please sign in to comment.