@@ -159,31 +159,59 @@ pub fn render(
159
159
}
160
160
161
161
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 ( ) ) ?;
163
163
if cmd == "get" {
164
- return Ok ( Some ( template . to_string ( ) ) ) ;
164
+ return Ok ( Some ( file . to_string ( ) ) ) ;
165
165
}
166
166
if cmd == "graphql" {
167
167
let mut variables = juniper:: Variables :: new ( ) ;
168
168
169
169
for ( k, v) in params {
170
170
variables. insert ( k. to_string ( ) , juniper:: InputValue :: scalar ( v) ) ;
171
171
}
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
+ } ;
174
202
let ( res, _errors) = juniper:: execute_sync (
175
- template ,
203
+ file ,
176
204
None ,
177
205
& graphql:: commit_schema ( commit_id) ,
178
206
& variables,
179
- & graphql:: context ( transaction, transaction_overlay ) ,
207
+ & graphql:: context ( transaction, transaction_mirror ) ,
180
208
) ?;
181
209
182
210
let j = serde_json:: to_string_pretty ( & res) ?;
183
211
return Ok ( Some ( j) ) ;
184
212
}
185
213
if cmd == "render" {
186
- template . to_string ( )
214
+ file . to_string ( )
187
215
} else {
188
216
return Err ( josh_error ( "no such cmd" ) ) ;
189
217
}
0 commit comments