Skip to content

Build your personal knowledge base with Trilium Notes

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

azivner18f2419bd6c7
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000000..15a15b218a
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>
\ No newline at end of file
diff --git a/src/anonymize.js b/src/anonymize.js
new file mode 100644
index 0000000000..65f559a595
--- /dev/null
+++ b/src/anonymize.js
@@ -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);
+});
\ No newline at end of file
diff --git a/src/services/anonymization.js b/src/services/anonymization.js
index 8db63aba8f..53c614ddca 100644
--- a/src/services/anonymization.js
+++ b/src/services/anonymization.js
@@ -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 = {