@@ -60,16 +60,16 @@ func TestStorageConstructor(t *testing.T) {
60
60
61
61
// walks a tar.gz and looks for paths with the basename. It does not match
62
62
// symlinks properly at this time because that's painful.
63
- func walkTar (tarFile string , match string , dir bool ) (int64 , bool , error ) {
63
+ func walkTar (tarFile string , match string , dir bool ) (int64 , int64 , bool , error ) {
64
64
f , err := os .Open (tarFile )
65
65
if err != nil {
66
- return 0 , false , fmt .Errorf ("could not open file: %w" , err )
66
+ return 0 , 0 , false , fmt .Errorf ("could not open file: %w" , err )
67
67
}
68
68
defer f .Close ()
69
69
70
70
gzr , err := gzip .NewReader (f )
71
71
if err != nil {
72
- return 0 , false , fmt .Errorf ("could not unzip file: %w" , err )
72
+ return 0 , 0 , false , fmt .Errorf ("could not unzip file: %w" , err )
73
73
}
74
74
defer gzr .Close ()
75
75
@@ -79,24 +79,24 @@ func walkTar(tarFile string, match string, dir bool) (int64, bool, error) {
79
79
if err == io .EOF {
80
80
break
81
81
} else if err != nil {
82
- return 0 , false , fmt .Errorf ("corrupt tarball reading header: %w" , err )
82
+ return 0 , 0 , false , fmt .Errorf ("corrupt tarball reading header: %w" , err )
83
83
}
84
84
85
85
switch header .Typeflag {
86
86
case tar .TypeDir :
87
87
if header .Name == match && dir {
88
- return 0 , true , nil
88
+ return 0 , header . Mode , true , nil
89
89
}
90
90
case tar .TypeReg :
91
91
if header .Name == match {
92
- return header .Size , true , nil
92
+ return header .Size , header . Mode , true , nil
93
93
}
94
94
default :
95
95
// skip
96
96
}
97
97
}
98
98
99
- return 0 , false , nil
99
+ return 0 , 0 , false , nil
100
100
}
101
101
102
102
func TestStorage_Archive (t * testing.T ) {
@@ -134,7 +134,7 @@ func TestStorage_Archive(t *testing.T) {
134
134
if ! mustExist {
135
135
name = name [1 :]
136
136
}
137
- s , exist , err := walkTar (storage .LocalPath (artifact ), name , false )
137
+ s , m , exist , err := walkTar (storage .LocalPath (artifact ), name , false )
138
138
if err != nil {
139
139
t .Fatalf ("failed reading tarball: %v" , err )
140
140
}
@@ -148,13 +148,16 @@ func TestStorage_Archive(t *testing.T) {
148
148
t .Errorf ("tarball contained excluded file %q" , name )
149
149
}
150
150
}
151
+ if exist && m != defaultFileMode {
152
+ t .Fatalf ("%q mode %v != %v" , name , m , defaultFileMode )
153
+ }
151
154
}
152
155
for _ , name := range dirs {
153
156
mustExist := ! (name [0 :1 ] == "!" )
154
157
if ! mustExist {
155
158
name = name [1 :]
156
159
}
157
- _ , exist , err := walkTar (storage .LocalPath (artifact ), name , true )
160
+ _ , m , exist , err := walkTar (storage .LocalPath (artifact ), name , true )
158
161
if err != nil {
159
162
t .Fatalf ("failed reading tarball: %v" , err )
160
163
}
@@ -165,6 +168,10 @@ func TestStorage_Archive(t *testing.T) {
165
168
t .Errorf ("tarball contained excluded file %q" , name )
166
169
}
167
170
}
171
+ if exist && m != defaultDirMode {
172
+ t .Fatalf ("%q mode %v != %v" , name , m , defaultDirMode )
173
+ }
174
+
168
175
}
169
176
}
170
177
0 commit comments