summaryrefslogtreecommitdiff
path: root/zip
diff options
context:
space:
mode:
Diffstat (limited to 'zip')
-rw-r--r--zip/cmd/main.go5
-rw-r--r--zip/zip.go30
2 files changed, 9 insertions, 26 deletions
diff --git a/zip/cmd/main.go b/zip/cmd/main.go
index c4e1196d6..f49105a63 100644
--- a/zip/cmd/main.go
+++ b/zip/cmd/main.go
@@ -186,8 +186,6 @@ func main() {
emulateJar := flags.Bool("jar", false, "modify the resultant .zip to emulate the output of 'jar'")
writeIfChanged := flags.Bool("write_if_changed", false, "only update resultant .zip if it has changed")
- symlinks := flags.Bool("symlinks", true, "store symbolic links in zip instead of following them")
-
parallelJobs := flags.Int("parallel", runtime.NumCPU(), "number of parallel threads to use")
cpuProfile := flags.String("cpuprofile", "", "write cpu profile to file")
traceFile := flags.String("trace", "", "write trace to file")
@@ -218,10 +216,9 @@ func main() {
NumParallelJobs: *parallelJobs,
NonDeflatedFiles: nonDeflatedFiles,
WriteIfChanged: *writeIfChanged,
- StoreSymlinks: *symlinks,
})
if err != nil {
- fmt.Fprintln(os.Stderr, "error:", err.Error())
+ fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
diff --git a/zip/zip.go b/zip/zip.go
index d9645b84f..4a02531eb 100644
--- a/zip/zip.go
+++ b/zip/zip.go
@@ -107,7 +107,6 @@ type ZipWriter struct {
compressorPool sync.Pool
compLevel int
- followSymlinks pathtools.ShouldFollowSymlinks
}
type zipEntry struct {
@@ -133,7 +132,6 @@ type ZipArgs struct {
NumParallelJobs int
NonDeflatedFiles map[string]bool
WriteIfChanged bool
- StoreSymlinks bool
}
const NOQUOTE = '\x00'
@@ -214,16 +212,12 @@ func Run(args ZipArgs) (err error) {
args.AddDirectoryEntriesToZip = true
}
- // Have Glob follow symlinks if they are not being stored as symlinks in the zip file.
- followSymlinks := pathtools.ShouldFollowSymlinks(!args.StoreSymlinks)
-
w := &ZipWriter{
- time: jar.DefaultTime,
- createdDirs: make(map[string]string),
- createdFiles: make(map[string]string),
- directories: args.AddDirectoryEntriesToZip,
- compLevel: args.CompressionLevel,
- followSymlinks: followSymlinks,
+ time: jar.DefaultTime,
+ createdDirs: make(map[string]string),
+ createdFiles: make(map[string]string),
+ directories: args.AddDirectoryEntriesToZip,
+ compLevel: args.CompressionLevel,
}
pathMappings := []pathMapping{}
@@ -232,14 +226,14 @@ func Run(args ZipArgs) (err error) {
for _, fa := range args.FileArgs {
var srcs []string
for _, s := range fa.SourceFiles {
- globbed, _, err := pathtools.Glob(s, nil, followSymlinks)
+ globbed, _, err := pathtools.Glob(s, nil, pathtools.DontFollowSymlinks)
if err != nil {
return err
}
srcs = append(srcs, globbed...)
}
if fa.GlobDir != "" {
- globbed, _, err := pathtools.Glob(filepath.Join(fa.GlobDir, "**/*"), nil, followSymlinks)
+ globbed, _, err := pathtools.Glob(filepath.Join(fa.GlobDir, "**/*"), nil, pathtools.DontFollowSymlinks)
if err != nil {
return err
}
@@ -478,15 +472,7 @@ func (z *ZipWriter) addFile(dest, src string, method uint16, emulateJar bool) er
var fileSize int64
var executable bool
- var s os.FileInfo
- var err error
- if z.followSymlinks {
- s, err = os.Stat(src)
- } else {
- s, err = os.Lstat(src)
- }
-
- if err != nil {
+ if s, err := os.Lstat(src); err != nil {
return err
} else if s.IsDir() {
if z.directories {