// sameConfig reports whether src and dest config files are equal.
// Two config files are equal when they have the same file contents and
// Unix permissions. The owner, group, and mode must match.
// It return false in other cases.
sameConfig reports whether src and dest config files are equal.
Two config files are equal when they have the same file contents and
Unix permissions. The owner, group, and mode must match.
It return false in other cases.
// sameConfig reports whether src and dest config files are equal . // Two config files are equal when they have the same file contents and // Unix permissions . The owner group and mode must match . // It return false in other cases .
func sameConfig(src, dest string) (bool, error) {
	if !isFileExist(dest) {
		return false, nil
	}
	d, err := fileStat(dest)
	if err != nil {
		return false, err
	}
	s, err := fileStat(src)
	if err != nil {
		return false, err
	}
	if d.Uid != s.Uid {
		log.Info(fmt.Sprintf("%s has UID %d should be %d", dest, d.Uid, s.Uid))
	}
	if d.Gid != s.Gid {
		log.Info(fmt.Sprintf("%s has GID %d should be %d", dest, d.Gid, s.Gid))
	}
	if d.Mode != s.Mode {
		log.Info(fmt.Sprintf("%s has mode %s should be %s", dest, os.FileMode(d.Mode), os.FileMode(s.Mode)))
	}
	if d.Md5 != s.Md5 {
		log.Info(fmt.Sprintf("%s has md5sum %s should be %s", dest, d.Md5, s.Md5))
	}
	if d.Uid != s.Uid || d.Gid != s.Gid || d.Mode != s.Mode || d.Md5 != s.Md5 {
		return false, nil
	}
	return true, nil
}
func sameConfig ( src , dest string ) ( bool , error ) { if ! isFileExist ( dest ) { return false , nil } d , err := fileStat ( dest ) if err != nil { return false , err } s , err := fileStat ( src ) if err != nil { return false , err } if d . Uid != s . Uid { log . Info ( fmt . Sprintf ( " " , dest , d . Uid , s . Uid ) ) } if d . Gid != s . Gid { log . Info ( fmt . Sprintf ( " " , dest , d . Gid , s . Gid ) ) } if d . Mode != s . Mode { log . Info ( fmt . Sprintf ( " " , dest , os . FileMode ( d . Mode ) , os . FileMode ( s . Mode ) ) ) } if d . Md5 != s . Md5 { log . Info ( fmt . Sprintf ( " " , dest , d . Md5 , s . Md5 ) ) } if d . Uid != s . Uid || d . Gid != s . Gid || d . Mode != s . Mode || d . Md5 != s . Md5 { return false , nil } return true , nil }
sameConfig reports whether src and dest config files are equal.
sameConfig reports whether src and dest config files are equal .