@@ -159,31 +159,59 @@ pub fn render(
159159 }
160160
161161 let template = if let Ok ( blob) = obj. peel_to_blob ( ) {
162- let template = std:: str:: from_utf8 ( blob. content ( ) ) ?;
162+ let file = std:: str:: from_utf8 ( blob. content ( ) ) ?;
163163 if cmd == "get" {
164- return Ok ( Some ( template . to_string ( ) ) ) ;
164+ return Ok ( Some ( file . to_string ( ) ) ) ;
165165 }
166166 if cmd == "graphql" {
167167 let mut variables = juniper:: Variables :: new ( ) ;
168168
169169 for ( k, v) in params {
170170 variables. insert ( k. to_string ( ) , juniper:: InputValue :: scalar ( v) ) ;
171171 }
172- let transaction = cache:: Transaction :: open ( transaction. repo ( ) . path ( ) , None ) ?;
173- let transaction_overlay = cache:: Transaction :: open ( transaction. repo ( ) . path ( ) , None ) ?;
172+ let ( transaction, transaction_mirror) = if let Ok ( to) = cache:: Transaction :: open (
173+ & transaction
174+ . repo ( )
175+ . path ( )
176+ . parent ( )
177+ . ok_or ( josh_error ( "parent" ) ) ?
178+ . join ( "overlay" ) ,
179+ None ,
180+ ) {
181+ to. repo ( ) . odb ( ) ?. add_disk_alternate (
182+ & transaction
183+ . repo ( )
184+ . path ( )
185+ . parent ( )
186+ . ok_or ( josh_error ( "parent" ) ) ?
187+ . join ( "mirror" )
188+ . join ( "objects" )
189+ . to_str ( )
190+ . unwrap ( ) ,
191+ ) ?;
192+ (
193+ to,
194+ cache:: Transaction :: open ( & transaction. repo ( ) . path ( ) , None ) ?,
195+ )
196+ } else {
197+ (
198+ cache:: Transaction :: open ( transaction. repo ( ) . path ( ) , None ) ?,
199+ cache:: Transaction :: open ( transaction. repo ( ) . path ( ) , None ) ?,
200+ )
201+ } ;
174202 let ( res, _errors) = juniper:: execute_sync (
175- template ,
203+ file ,
176204 None ,
177205 & graphql:: commit_schema ( commit_id) ,
178206 & variables,
179- & graphql:: context ( transaction, transaction_overlay ) ,
207+ & graphql:: context ( transaction, transaction_mirror ) ,
180208 ) ?;
181209
182210 let j = serde_json:: to_string_pretty ( & res) ?;
183211 return Ok ( Some ( j) ) ;
184212 }
185213 if cmd == "render" {
186- template . to_string ( )
214+ file . to_string ( )
187215 } else {
188216 return Err ( josh_error ( "no such cmd" ) ) ;
189217 }
0 commit comments