2
2
// SPDX-License-Identifier: MPL-2.0
3
3
4
4
use crate :: utils:: fs_host;
5
- use crate :: wit:: metatype:: typegraph:: host:: read_file;
6
- use common:: {
7
- archive:: encode_bytes_to_base_64,
8
- typegraph:: {
9
- runtimes:: wasmedge:: WasiMatData ,
10
- utils:: { map_from_object, object_from_map} ,
11
- Typegraph ,
12
- } ,
5
+ use common:: typegraph:: {
6
+ runtimes:: wasmedge:: WasiMatData ,
7
+ utils:: { map_from_object, object_from_map} ,
8
+ Typegraph ,
13
9
} ;
14
10
use std:: path:: PathBuf ;
15
11
@@ -19,6 +15,7 @@ pub struct WasmedgeProcessor;
19
15
20
16
impl PostProcessor for WasmedgeProcessor {
21
17
fn postprocess ( self , tg : & mut Typegraph ) -> Result < ( ) , crate :: errors:: TgError > {
18
+ let tg_name = tg. name ( ) . unwrap ( ) ;
22
19
for mat in tg. materializers . iter_mut ( ) {
23
20
if mat. name . as_str ( ) == "wasi" {
24
21
let mut mat_data: WasiMatData =
@@ -28,8 +25,14 @@ impl PostProcessor for WasmedgeProcessor {
28
25
} ;
29
26
30
27
let wasi_path = fs_host:: make_absolute ( & PathBuf :: from ( path) ) ?;
31
- let bytes = read_file ( & wasi_path. display ( ) . to_string ( ) ) ?;
32
- mat_data. wasm = encode_bytes_to_base_64 ( bytes) . map_err ( |e| e. to_string ( ) ) ?;
28
+ let file_name = path. split ( '/' ) . last ( ) . unwrap ( ) ;
29
+ let artifact_hash = mat_data. artifact_hash . clone ( ) ;
30
+ let wasm_path = format ! (
31
+ "tmp/metatype-artifacts/{}/files/{}.{}" ,
32
+ tg_name, file_name, artifact_hash
33
+ ) ;
34
+
35
+ mat_data. wasm = wasm_path;
33
36
34
37
mat. data = map_from_object ( mat_data) . map_err ( |e| e. to_string ( ) ) ?;
35
38
tg. deps . push ( wasi_path) ;
0 commit comments