Skip to content

Commit

Permalink
Join options to use numeric user and group id
Browse files Browse the repository at this point in the history
* join NumericUid and NumericGid in Tar struct
* name the new option NumericUidGid
  • Loading branch information
breezerider committed Sep 14, 2023
1 parent a124ffa commit 574dafb
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ func init() {
}

type Tar struct {
// If true, leave only numeric user id
NumericUid bool

// If true, leave only numeric group id
NumericGid bool
// If true, leave only numeric user and group id
NumericUidGid bool

// If true, errors encountered during reading or writing
// a file within an archive will be logged and the
Expand Down Expand Up @@ -87,10 +84,8 @@ func (t Tar) writeFileToArchive(ctx context.Context, tw *tar.Writer, file File)
return fmt.Errorf("file %s: creating header: %w", file.NameInArchive, err)
}
hdr.Name = file.NameInArchive // complete path, since FileInfoHeader() only has base name
if t.NumericUid {
if t.NumericUidGid {
hdr.Uname = ""
}
if t.NumericGid {
hdr.Gname = ""
}

Expand Down

0 comments on commit 574dafb

Please sign in to comment.