Skip to content

Commit

Permalink
Add ChmodFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jul 19, 2019
1 parent ab73f9a commit 0414179
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type Syncer struct {
NoTimes bool
// NoChmod disables permission mode syncing.
NoChmod bool
// Implement this function to skip Chmod syncing for only certain files
// or directories. Return true to skip Chmod.
ChmodFilter func(dst, src os.FileInfo) bool

// TODO add options for not checking content for equality

Expand Down Expand Up @@ -219,7 +222,11 @@ func (s *Syncer) syncstats(dst, src string) {
check(err2)

// update dst's permission bits
if !s.NoChmod {
noChmod := s.NoChmod
if !noChmod && s.ChmodFilter != nil {
noChmod = s.ChmodFilter(dstat, sstat)
}
if !noChmod {
if dstat.Mode().Perm() != sstat.Mode().Perm() {
check(s.DestFs.Chmod(dst, sstat.Mode().Perm()))
}
Expand Down

0 comments on commit 0414179

Please sign in to comment.