@@ -13,7 +13,7 @@ import (
13
13
// UpdateKeywordFunc is the signature for a function that will restore a file's
14
14
// attributes. Where path is relative path to the file, and value to be
15
15
// restored to.
16
- type UpdateKeywordFunc func (keyword Keyword , path string , value string ) (os.FileInfo , error )
16
+ type UpdateKeywordFunc func (path string , kv KeyVal ) (os.FileInfo , error )
17
17
18
18
// UpdateKeywordFuncs is the registered list of functions to update file attributes.
19
19
// Keyed by the keyword as it would show up in the manifest
@@ -26,8 +26,8 @@ var UpdateKeywordFuncs = map[Keyword]UpdateKeywordFunc{
26
26
"xattr" : xattrUpdateKeywordFunc ,
27
27
}
28
28
29
- func uidUpdateKeywordFunc (keyword Keyword , path , value string ) (os.FileInfo , error ) {
30
- uid , err := strconv .Atoi (value )
29
+ func uidUpdateKeywordFunc (path string , kv KeyVal ) (os.FileInfo , error ) {
30
+ uid , err := strconv .Atoi (kv . Value () )
31
31
if err != nil {
32
32
return nil , err
33
33
}
@@ -37,8 +37,8 @@ func uidUpdateKeywordFunc(keyword Keyword, path, value string) (os.FileInfo, err
37
37
return os .Lstat (path )
38
38
}
39
39
40
- func gidUpdateKeywordFunc (keyword Keyword , path , value string ) (os.FileInfo , error ) {
41
- gid , err := strconv .Atoi (value )
40
+ func gidUpdateKeywordFunc (path string , kv KeyVal ) (os.FileInfo , error ) {
41
+ gid , err := strconv .Atoi (kv . Value () )
42
42
if err != nil {
43
43
return nil , err
44
44
}
@@ -48,12 +48,12 @@ func gidUpdateKeywordFunc(keyword Keyword, path, value string) (os.FileInfo, err
48
48
return os .Lstat (path )
49
49
}
50
50
51
- func modeUpdateKeywordFunc (keyword Keyword , path , value string ) (os.FileInfo , error ) {
52
- vmode , err := strconv .ParseInt (value , 8 , 32 )
51
+ func modeUpdateKeywordFunc (path string , kv KeyVal ) (os.FileInfo , error ) {
52
+ vmode , err := strconv .ParseInt (kv . Value () , 8 , 32 )
53
53
if err != nil {
54
54
return nil , err
55
55
}
56
- logrus .Debugf ("path: %q, value : %q, vmode: %o" , path , value , vmode )
56
+ logrus .Debugf ("path: %q, kv.Value() : %q, vmode: %o" , path , kv . Value () , vmode )
57
57
if err := os .Chmod (path , os .FileMode (vmode )); err != nil {
58
58
return nil , err
59
59
}
@@ -63,13 +63,13 @@ func modeUpdateKeywordFunc(keyword Keyword, path, value string) (os.FileInfo, er
63
63
// since tar_time will only be second level precision, then when restoring the
64
64
// filepath from a tar_time, then compare the seconds first and only Chtimes if
65
65
// the seconds value is different.
66
- func tartimeUpdateKeywordFunc (keyword Keyword , path , value string ) (os.FileInfo , error ) {
66
+ func tartimeUpdateKeywordFunc (path string , kv KeyVal ) (os.FileInfo , error ) {
67
67
info , err := os .Lstat (path )
68
68
if err != nil {
69
69
return nil , err
70
70
}
71
71
72
- v := strings .SplitN (value , "." , 2 )
72
+ v := strings .SplitN (kv . Value () , "." , 2 )
73
73
if len (v ) != 2 {
74
74
return nil , fmt .Errorf ("expected a number like 1469104727.000000000" )
75
75
}
@@ -92,8 +92,8 @@ func tartimeUpdateKeywordFunc(keyword Keyword, path, value string) (os.FileInfo,
92
92
}
93
93
94
94
// this is nano second precision
95
- func timeUpdateKeywordFunc (keyword Keyword , path , value string ) (os.FileInfo , error ) {
96
- v := strings .SplitN (value , "." , 2 )
95
+ func timeUpdateKeywordFunc (path string , kv KeyVal ) (os.FileInfo , error ) {
96
+ v := strings .SplitN (kv . Value () , "." , 2 )
97
97
if len (v ) != 2 {
98
98
return nil , fmt .Errorf ("expected a number like 1469104727.871937272" )
99
99
}
0 commit comments