allow creating anonymized database from command line as well, fixes #200

This commit is contained in:
azivner 2018-10-25 18:03:28 +02:00
parent 9f0860edab
commit 18f2419bd6
3 changed files with 14 additions and 0 deletions

4
.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

7
src/anonymize.js Normal file
View File

@ -0,0 +1,7 @@
const anonymizationService = require('./services/anonymization');
anonymizationService.anonymize().then(filePath => {
console.log("Anonymized file has been saved to:", filePath);
process.exit(0);
});

View File

@ -19,12 +19,15 @@ async function anonymize() {
await db.run("UPDATE notes SET title = 'title', content = 'text'");
await db.run("UPDATE note_revisions SET title = 'title', content = 'text'");
await db.run("UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL");
await db.run("UPDATE images SET data = NULL");
await db.run(`UPDATE options SET value = 'anonymized' WHERE name IN
('documentSecret', 'encryptedDataKey', 'passwordVerificationHash',
'passwordVerificationSalt', 'passwordDerivedKeySalt')`);
await db.run("VACUUM");
await db.close();
return anonymizedFile;
}
module.exports = {