@@ -38,26 +38,33 @@ func (rt *Transfer) recvIdMapping1(localId func(id int32, name string) int32) (m
3838
3939// rsync/uidlist.c:recv_id_list
4040func (rt * Transfer ) RecvIdList () (users map [int32 ]mapping , groups map [int32 ]mapping , _ error ) {
41- var err error
42- users , err = rt .recvIdMapping1 (func (remoteUid int32 , remoteUsername string ) int32 {
43- // TODO: look up local uid by username
44- return remoteUid
45- })
46- if err != nil {
47- return nil , nil , err
48- }
49- for remoteUid , mapping := range users {
50- log .Printf ("remote uid %d(%s) maps to local uid %d" , remoteUid , mapping .Name , mapping .LocalId )
51- }
52- groups , err = rt .recvIdMapping1 (func (remoteGid int32 , remoteGroupname string ) int32 {
53- // TODO: look up local gid by groupname
54- return remoteGid
55- })
56- if err != nil {
57- return nil , nil , err
41+ if rt .Opts .PreserveUid {
42+ var err error
43+ users , err = rt .recvIdMapping1 (func (remoteUid int32 , remoteUsername string ) int32 {
44+ // TODO: look up local uid by username
45+ return remoteUid
46+ })
47+ if err != nil {
48+ return nil , nil , err
49+ }
50+ for remoteUid , mapping := range users {
51+ log .Printf ("remote uid %d(%s) maps to local uid %d" , remoteUid , mapping .Name , mapping .LocalId )
52+ }
5853 }
59- for remoteGid , mapping := range groups {
60- log .Printf ("remote gid %d(%s) maps to local gid %d" , remoteGid , mapping .Name , mapping .LocalId )
54+
55+ if rt .Opts .PreserveGid {
56+ var err error
57+ groups , err = rt .recvIdMapping1 (func (remoteGid int32 , remoteGroupname string ) int32 {
58+ // TODO: look up local gid by groupname
59+ return remoteGid
60+ })
61+ if err != nil {
62+ return nil , nil , err
63+ }
64+ for remoteGid , mapping := range groups {
65+ log .Printf ("remote gid %d(%s) maps to local gid %d" , remoteGid , mapping .Name , mapping .LocalId )
66+ }
6167 }
68+
6269 return users , groups , nil
6370}
0 commit comments