MCPcopy
hub / github.com/streetwriters/notesnook / pull

Function pull

apps/web/src/common/index.ts:144–178  ·  view source on GitHub ↗
(controller)

Source from the content-addressed store, hash-verified

142 await new ReadableStream<ZipFile>({
143 start() {},
144 async pull(controller) {
145 for await (const output of db.backup!.export({
146 type: "web",
147 encrypt: encryptedBackups,
148 mode
149 })) {
150 if (output.type === "file") {
151 const file = output;
152 report({
153 text: background
154 ? `Creating backup (${file.path})`
155 : `Saving file ${file.path}`
156 });
157 controller.enqueue({
158 path: file.path,
159 data: encoder.encode(file.data)
160 });
161 } else if (output.type === "attachment") {
162 report({
163 text: background
164 ? `Creating backup (${output.hash})`
165 : `Saving attachment ${output.hash}`,
166 total: output.total,
167 current: output.current
168 });
169 const handle = await streamablefs.readFile(output.hash);
170 if (!handle) continue;
171 controller.enqueue({
172 path: output.path,
173 data: handle.readable
174 });
175 }
176 }
177 controller.close();
178 }
179 })
180 .pipeThrough(createZipStream())
181 .pipeTo(writeStream);

Callers

nothing calls this directly

Calls 4

readFileMethod · 0.65
closeMethod · 0.65
exportMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected