summaryrefslogtreecommitdiff
path: root/includes/data.backup/migrate.js
diff options
context:
space:
mode:
Diffstat (limited to 'includes/data.backup/migrate.js')
-rw-r--r--includes/data.backup/migrate.js94
1 files changed, 0 insertions, 94 deletions
diff --git a/includes/data.backup/migrate.js b/includes/data.backup/migrate.js
deleted file mode 100644
index 716096f..0000000
--- a/includes/data.backup/migrate.js
+++ /dev/null
@@ -1,94 +0,0 @@
-const fs = require('fs');
-
-for (let file of fs.readdirSync(".").filter(i => i.endsWith("-metadata.json"))) {
- let size = fs.readFileSync(file).toString().length;
- let json = JSON.parse(fs.readFileSync(file).toString());
- console.log("-- " + file + " --");
-
- if (!json['bitset']) {
- console.log("Migrating file...");
- let p1r = "0".repeat(2 - json['shared_memory'].toString(2).length) + json['shared_memory'].toString(2);
- let p2r = json['median'] ? "1" : "0";
- let p3r = "0".repeat(2 - json['little'].toString(2).length) + json['little'].toString(2);
- let p4r = json['protector'] ? "1" : "0";
- let p5r = json['fictive'] ? "1" : "0";
- let p6r = json['not_talking'] ? "1" : "0";
- let p7r = json['host'] ? "1" : "0";
- let p8a = json['species'][0];
- let p9a = json['species'][1];
-
- let p8r = "0000";
- switch (p8a) {
- case "earth":
- p8r = "0001";
- break;
-
- case "unicorn":
- p8r = "0010";
- break;
-
- case "pegasus":
- p8r = "0011";
- break;
-
- case "alicorn":
- p8r = "0100";
- break;
-
- case "batpony":
- p8r = "0101";
- break;
-
- case "crystal":
- p8r = "0110";
- break;
- }
-
- let p9r = "0000";
- switch (p9a) {
- case "earth":
- p9r = "0001";
- break;
-
- case "unicorn":
- p9r = "0010";
- break;
-
- case "pegasus":
- p9r = "0011";
- break;
-
- case "alicorn":
- p9r = "0100";
- break;
-
- case "batpony":
- p9r = "0101";
- break;
-
- case "crystal":
- p9r = "0110";
- break;
- }
-
- console.log("Generated bitset: " + p1r + p2r + p3r + p4r + p5r + p6r + p7r + p8r + p9r + "0000000");
-
- let ret = {
- bitset: parseInt(p1r + p2r + p3r + p4r + p5r + p6r + p7r + p8r + p9r + "0000000", 2),
- regression: json['regression'] ?? null,
- marefriends: json['marefriends'] ?? [],
- sisters: json['sisters'] ?? [],
- caretakers: json['caretakers'] ?? []
- }
-
- console.log("Saving...");
- fs.writeFileSync(file, JSON.stringify(ret, null, 2));
- let now = JSON.stringify(ret, null, 2).length;
-
- console.log("Saved space: " + (size - now) + " bytes, " + (((size - now) / size) * 100).toFixed(2) + "%");
- } else {
- console.log("File has already been migrated, ignoring.");
- }
-
- console.log("");
-} \ No newline at end of file