File tree Expand file tree Collapse file tree 3 files changed +10
-19
lines changed
src/bin/nydus-image/builder Expand file tree Collapse file tree 3 files changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ impl TocIndex {
298298 fn load ( path : & Path ) -> Result < TocIndex > {
299299 let index_file = File :: open ( path)
300300 . with_context ( || format ! ( "failed to open stargz index file {:?}" , path) ) ?;
301- let toc_index: TocIndex = serde_json:: from_reader ( index_file)
301+ let mut toc_index: TocIndex = serde_json:: from_reader ( index_file)
302302 . with_context ( || format ! ( "invalid stargz index file {:?}" , path) ) ?;
303303
304304 if toc_index. version != 1 {
@@ -308,6 +308,15 @@ impl TocIndex {
308308 ) ) ) ;
309309 }
310310
311+ // Append root directory entry if not exists.
312+ if !toc_index. entries . is_empty ( ) && toc_index. entries [ 0 ] . name ( ) ? != PathBuf :: from ( "/" ) {
313+ let root_entry = TocEntry {
314+ toc_type : String :: from ( "dir" ) ,
315+ ..Default :: default ( )
316+ } ;
317+ toc_index. entries . insert ( 0 , root_entry) ;
318+ }
319+
311320 Ok ( toc_index)
312321 }
313322}
Original file line number Diff line number Diff line change 11{
22 "version" : 1 ,
33 "entries" : [
4- {
5- "name" : " " ,
6- "type" : " dir" ,
7- "modtime" : " 2020-09-10T07:40:29Z" ,
8- "mode" : 493 ,
9- "userName" : " root" ,
10- "groupName" : " root" ,
11- "NumLink" : 0
12- },
134 {
145 "name" : " root-large" ,
156 "type" : " reg" ,
Original file line number Diff line number Diff line change 11{
22 "version" : 1 ,
33 "entries" : [
4- {
5- "name" : " " ,
6- "type" : " dir" ,
7- "modtime" : " 2020-09-10T06:43:07Z" ,
8- "mode" : 493 ,
9- "userName" : " root" ,
10- "groupName" : " root" ,
11- "NumLink" : 0
12- },
134 {
145 "name" : " sub/" ,
156 "type" : " dir" ,
You can’t perform that action at this time.
0 commit comments