@@ -159,31 +159,68 @@ 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 (
195
+ & transaction
196
+ . repo ( )
197
+ . path ( )
198
+ . parent ( )
199
+ . ok_or ( josh_error ( "parent" ) ) ?
200
+ . join ( "mirror" )
201
+ . join ( "objects" ) ,
202
+ None ,
203
+ ) ?,
204
+ )
205
+ } else {
206
+ (
207
+ cache:: Transaction :: open ( transaction. repo ( ) . path ( ) , None ) ?,
208
+ cache:: Transaction :: open ( transaction. repo ( ) . path ( ) , None ) ?,
209
+ )
210
+ } ;
174
211
let ( res, _errors) = juniper:: execute_sync (
175
- template ,
212
+ file ,
176
213
None ,
177
214
& graphql:: commit_schema ( commit_id) ,
178
215
& variables,
179
- & graphql:: context ( transaction, transaction_overlay ) ,
216
+ & graphql:: context ( transaction, transaction_mirror ) ,
180
217
) ?;
181
218
182
219
let j = serde_json:: to_string_pretty ( & res) ?;
183
220
return Ok ( Some ( j) ) ;
184
221
}
185
222
if cmd == "render" {
186
- template . to_string ( )
223
+ file . to_string ( )
187
224
} else {
188
225
return Err ( josh_error ( "no such cmd" ) ) ;
189
226
}
0 commit comments