MCPcopy Create free account
hub / github.com/Criptext/Criptext-Email-React-Client / start

Function start

electron_app/src/backup/exporter.js:28–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26let password;
27
28const start = async () => {
29 var args = process.argv.slice(2);
30 const dbPath = args[0];
31 const backupPath = args[1];
32 const recipientId = args[2];
33 const tempBackupDirectory = args[3];
34
35 if (!key) {
36 throw new Error(`Database key was never received`);
37 }
38
39 const outputPath = path.join(tempBackupDirectory, 'unencrypt.exp');
40
41 checkTempBackupDirectory(tempBackupDirectory);
42 copyDatabase(dbPath, tempBackupDirectory);
43
44 let account;
45 try {
46 await initDatabaseEncrypted({
47 key: key,
48 dbpath: path.join(tempBackupDirectory, 'CriptextEncrypt.db'),
49 sync: false
50 });
51 account = await Account().findOne({
52 where: {
53 recipientId
54 }
55 });
56 } catch (ex) {
57 removeTempBackupDirectoryRecursive(tempBackupDirectory);
58 throw new Error(`Error connecting to db ${ex}`);
59 }
60
61 const [reId, domain = APP_DOMAIN] = recipientId.split('@');
62 try {
63 const accountObj = {
64 email: `${reId}@${domain}`,
65 username: reId,
66 domain: domain,
67 name: account.name,
68 id: account.id
69 };
70
71 await exportEncryptDatabaseToFile({
72 outputPath,
73 accountObj,
74 progressCallback: handleProgress,
75 databaseKey: key
76 });
77 } catch (ex) {
78 removeTempBackupDirectoryRecursive(tempBackupDirectory);
79 throw new Error(`Error creating backup ${ex}`);
80 }
81
82 try {
83 if (password) {
84 const { key, iv, salt } = generateKeyAndIvFromPassword(password);
85 await encryptStreamFile({

Callers 1

exporter.jsFile · 0.70

Calls 12

copyDatabaseFunction · 0.85
initDatabaseEncryptedFunction · 0.85
zipStreamFileFunction · 0.85
getFileSizeInBytesFunction · 0.85
handleRegisterBackupFunction · 0.85
checkTempBackupDirectoryFunction · 0.70
encryptStreamFileFunction · 0.70
sleepFunction · 0.70
AccountClass · 0.50

Tested by

no test coverage detected