mirror of
https://github.com/c4milo/unpackit.git
synced 2025-09-26 19:01:11 +08:00
Preserves file permissions
This commit is contained in:
@@ -254,10 +254,11 @@ func unpackZip(zr *zip.Reader, destPath string) (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
file, err := os.Create(filepath.Join(destPath, filePath))
|
||||
file, err := os.OpenFile(filepath.Join(destPath, filePath), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, f.Mode())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := file.Close(); err != nil {
|
||||
log.Println(err)
|
||||
@@ -319,6 +320,7 @@ func Untar(data io.Reader, destPath string) (string, error) {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
file.Chmod(os.FileMode(hdr.Mode))
|
||||
|
||||
if _, err := io.Copy(file, tr); err != nil {
|
||||
return rootdir, err
|
||||
|
Reference in New Issue
Block a user