| 36 | }; |
| 37 | |
| 38 | const copyDatabase = (dbPath, tempBackupDirectory) => { |
| 39 | const dbshm = `${dbPath}-shm`; |
| 40 | const dbwal = `${dbPath}-wal`; |
| 41 | |
| 42 | if (!fs.existsSync(dbPath)) { |
| 43 | throw new Error('No Database Found'); |
| 44 | } |
| 45 | |
| 46 | fs.copyFileSync(dbPath, path.join(tempBackupDirectory, 'CriptextEncrypt.db')); |
| 47 | |
| 48 | if (fs.existsSync(dbshm)) { |
| 49 | fs.copyFileSync( |
| 50 | dbshm, |
| 51 | path.join(tempBackupDirectory, 'CriptextEncrypt.db-shm') |
| 52 | ); |
| 53 | } |
| 54 | if (fs.existsSync(dbwal)) { |
| 55 | fs.copyFileSync( |
| 56 | dbwal, |
| 57 | path.join(tempBackupDirectory, 'CriptextEncrypt.db-wal') |
| 58 | ); |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | const loadJson = path => { |
| 63 | if (!fs.existsSync(path)) return {}; |