mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 12:03:11 +00:00
skip migrations if the user has disabled logging
This commit is contained in:
parent
d67277d996
commit
dfed1dd757
1 changed files with 20 additions and 3 deletions
|
@ -29,23 +29,40 @@ async function runMigrations(user: string) {
|
|||
throw new Error(`invalid user ${user}`);
|
||||
}
|
||||
|
||||
return migrateUser(user);
|
||||
return migrateUser(manager, user);
|
||||
}
|
||||
|
||||
for (const name of users) {
|
||||
await migrateUser(name);
|
||||
await migrateUser(manager, name);
|
||||
// if any migration fails we blow up,
|
||||
// chances are the rest won't complete either
|
||||
}
|
||||
}
|
||||
|
||||
// runs sqlite migrations for a user, which must exist
|
||||
async function migrateUser(user: string) {
|
||||
async function migrateUser(manager: ClientManager, user: string) {
|
||||
log.info("handling user", user);
|
||||
|
||||
if (!isUserLogEnabled(manager, user)) {
|
||||
log.info("logging disabled for user", user, ". Skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
const sqlite = new SqliteMessageStorage(user);
|
||||
await sqlite.enable(); // enable runs migrations
|
||||
await sqlite.close();
|
||||
log.info("user", user, "migrated successfully");
|
||||
}
|
||||
|
||||
function isUserLogEnabled(manager: ClientManager, user: string): boolean {
|
||||
const conf = manager.readUserConfig(user);
|
||||
|
||||
if (!conf) {
|
||||
log.error("Could not open user configuration of", user);
|
||||
return false;
|
||||
}
|
||||
|
||||
return conf.log;
|
||||
}
|
||||
|
||||
export default program;
|
||||
|
|
Loading…
Reference in a new issue