Skip to content

Commit

Permalink
Improve zip change item perm
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie authored Aug 29, 2024
1 parent 1af2833 commit c1ba536
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/barrow/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ func (b *BarrowCtx) addItem2Zip(z *zip.Writer, item *FileItem, method uint16, pr
if err != nil {
return err
}

if len(item.Permissions) != 0 {
if m, err := strconv.ParseInt(item.Permissions, 8, 64); err == nil {
hdr.SetMode(fs.FileMode(m))
}
}

if si.IsDir() {
hdr.Name = filepath.ToSlash(nameInArchive) + "/"
hdr.Method = zip.Store
Expand All @@ -94,12 +101,7 @@ func (b *BarrowCtx) addItem2Zip(z *zip.Writer, item *FileItem, method uint16, pr
}
return nil
}
mode := si.Mode().Perm()
if len(item.Permissions) != 0 {
if m, err := strconv.ParseInt(item.Permissions, 8, 64); err == nil {
mode = fs.FileMode(m)
}
}

hdr.SetMode(mode)
hdr.Method = method
hdr.Modified = si.ModTime()
Expand Down

0 comments on commit c1ba536

Please sign in to comment.