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

Function createZip

apps/mobile/app/services/exporter.ts:274–318  ·  view source on GitHub ↗
(
  totalNotes: number,
  cacheFolder: string,
  type: "txt" | "pdf" | "md" | "html" | "md-frontmatter",
  path: string,
  callback: (progress?: string) => void
)

Source from the content-addressed store, hash-verified

272}
273
274async function createZip(
275 totalNotes: number,
276 cacheFolder: string,
277 type: "txt" | "pdf" | "md" | "html" | "md-frontmatter",
278 path: string,
279 callback: (progress?: string) => void
280) {
281 const fileName = `nn-export-${totalNotes}-${type}-${Date.now()}.zip`;
282 const dir = path;
283 try {
284 callback("Creating zip");
285 const zipOutputPath =
286 Platform.OS === "ios"
287 ? join(path, fileName)
288 : join(RNFetchBlob.fs.dirs.CacheDir, fileName);
289 await zip(cacheFolder, zipOutputPath);
290
291 callback("Saving zip file");
292 if (Platform.OS === "android") {
293 const file = await ScopedStorage.createFile(
294 path,
295 fileName,
296 "application/zip"
297 );
298 path = file.uri;
299 await copyFileAsync("file://" + zipOutputPath, path);
300 await RNFetchBlob.fs.unlink(zipOutputPath);
301 callback();
302 } else {
303 path = zipOutputPath;
304 }
305 RNFetchBlob.fs.unlink(cacheFolder);
306 } catch (e) {
307 DatabaseLogger.error(e as Error);
308 }
309
310 return {
311 filePath: path,
312 fileDir: dir,
313 type: "application/zip",
314 name: "zip",
315 fileName: fileName,
316 count: totalNotes
317 };
318}
319
320async function createFile(
321 noteItem: ExportableNote,

Callers 2

bulkExportFunction · 0.85
exportNoteFunction · 0.85

Calls 5

callbackFunction · 0.85
copyFileAsyncFunction · 0.70
createFileMethod · 0.65
unlinkMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected