Skip to content

Commit

Permalink
misc/dist: include directories in distribution tar and zip files.
Browse files Browse the repository at this point in the history
Fixes #3458.

R=adg, dsymonds
CC=golang-dev
https://golang.org/cl/5969071
  • Loading branch information
davecheney authored and adg committed Apr 5, 2012
1 parent b16ec46 commit 4e9f704
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions misc/dist/bindist.go
Expand Up @@ -574,9 +574,6 @@ func makeTar(targ, workdir string) error {
if *verbose {
log.Printf("adding to tar: %s", name)
}
if fi.IsDir() {
return nil
}
hdr, err := tarFileInfoHeader(fi, path)
if err != nil {
return err
Expand All @@ -598,6 +595,9 @@ func makeTar(targ, workdir string) error {
if err != nil {
return fmt.Errorf("Error writing file %q: %v", name, err)
}
if fi.IsDir() {
return nil
}
r, err := os.Open(path)
if err != nil {
return err
Expand Down Expand Up @@ -626,9 +626,6 @@ func makeZip(targ, workdir string) error {
zw := zip.NewWriter(f)

err = filepath.Walk(workdir, func(path string, fi os.FileInfo, err error) error {
if fi.IsDir() {
return nil
}
if !strings.HasPrefix(path, workdir) {
log.Panicf("walked filename %q doesn't begin with workdir %q", path, workdir)
}
Expand All @@ -655,10 +652,17 @@ func makeZip(targ, workdir string) error {
}
fh.Name = name
fh.Method = zip.Deflate
if fi.IsDir() {
fh.Name += "/" // append trailing slash
fh.Method = zip.Store // no need to deflate 0 byte files
}
w, err := zw.CreateHeader(fh)
if err != nil {
return err
}
if fi.IsDir() {
return nil
}
r, err := os.Open(path)
if err != nil {
return err
Expand Down

0 comments on commit 4e9f704

Please sign in to comment.