MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / ply_storage_load_bytes

Function ply_storage_load_bytes

js/storage.js:126–151  ·  view source on GitHub ↗
(storage_id, relative_path_obj)

Source from the content-addressed store, hash-verified

124}
125
126function ply_storage_load_bytes(storage_id, relative_path_obj) {
127 var op_id = ply_storage_next_op_id();
128 var relative_path = consume_js_object(relative_path_obj);
129
130 (async function () {
131 try {
132 var root_handle = ply_storage_get_root(storage_id);
133 var parent = await ply_storage_resolve_parent_dir(root_handle, relative_path, false);
134 var file_handle = await parent.dir.getFileHandle(parent.file_name, { create: false });
135 var file = await file_handle.getFile();
136 var array_buffer = await file.arrayBuffer();
137 ply_storage_finish_ok(op_id, {
138 exists: 1,
139 data: new Uint8Array(array_buffer)
140 });
141 } catch (error) {
142 if (error && error.name === "NotFoundError") {
143 ply_storage_finish_ok(op_id, { exists: 0 });
144 return;
145 }
146 ply_storage_finish_err(op_id, error);
147 }
148 }());
149
150 return op_id;
151}
152
153function ply_storage_remove(storage_id, relative_path_obj) {
154 var op_id = ply_storage_next_op_id();

Callers 1

load_bytesMethod · 0.85

Calls 6

ply_storage_next_op_idFunction · 0.85
consume_js_objectFunction · 0.85
ply_storage_get_rootFunction · 0.85
ply_storage_finish_okFunction · 0.85
ply_storage_finish_errFunction · 0.85

Tested by

no test coverage detected