mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
zip: omit base dir.
This commit is contained in:
parent
486f9e13df
commit
7377e24abe
@ -18,16 +18,6 @@ func Zip(source, zipPath string) error {
|
||||
archive := zip.NewWriter(archiveFile)
|
||||
defer archive.Close()
|
||||
|
||||
info, err := os.Stat(source)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var baseDir string
|
||||
if info.IsDir() {
|
||||
baseDir = filepath.Base(source)
|
||||
}
|
||||
|
||||
return filepath.Walk(source, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
@ -42,9 +32,7 @@ func Zip(source, zipPath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if baseDir != "" {
|
||||
header.Name = filepath.Join(baseDir, strings.TrimPrefix(path, source))
|
||||
}
|
||||
header.Name = strings.TrimPrefix(path, source)
|
||||
|
||||
if info.IsDir() {
|
||||
header.Name += "/"
|
||||
|
Loading…
Reference in New Issue
Block a user