Files
minisrv/zefie_wtvp_minisrv/migrate_accounts.js
zefie c2a3081afd v0.9.36
- BREAKING CHANGE from v0.9.35 and eariler: Move accounts into subfolder of SessionStore
 - viewergen and viewer updates from @GraspYonOx
 - new homepage theme inspired by @GraspYonOx
 - connect setup also mostly by @GraspYonOx
 - numerous bug fixes
 - nntp-server-zefie is now on npmjs
 - implement proper nodejs debugging
   - will start to phase out using console.log for actual debugging
   - existing "debug" (verbose) messages will stay as is
   - future code debugging will use debug() to debug WIP, therefore not showing to most users if it is accidently left in
2022-11-29 08:29:31 -05:00

27 lines
1.1 KiB
JavaScript

var classPath = __dirname + "/includes/";
const { WTVShared } = require(classPath + "WTVShared.js");
const wtvshared = new WTVShared(); // creates minisrv_config
classPath = wtvshared.getAbsolutePath(classPath, __dirname);
const WTVClientSessionData = require(classPath + "/WTVClientSessionData.js");
minisrv_config = wtvshared.getMiniSrvConfig();
const wtvcsd = new WTVClientSessionData(minisrv_config)
const fs = require('fs')
const path = require('path')
var old_account_dir = minisrv_config.config.SessionStore;
var new_account_dir = wtvcsd.getAccountStoreDirectory();
if (!fs.existsSync(new_account_dir)) fs.mkdirSync(new_account_dir);
total = 0;
fs.readdirSync(old_account_dir).forEach(file => {
if (file === "accounts" || file === "minisrv_internal_nntp" || file === "client registration and session data will populate here.txt") return;
fs.renameSync(old_account_dir + path.sep + file, new_account_dir + path.sep + file)
console.log(" * Migrated", old_account_dir + path.sep + file, "to", new_account_dir + path.sep + file);
total++;
});
console.log(" *", total, "accounts migrated.");