Skip to content

Commit

Permalink
more watchers disabled with setting
Browse files Browse the repository at this point in the history
related to #444 and #477
  • Loading branch information
MrBrax committed Nov 27, 2023
1 parent 3481dcd commit 9f120ae
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 157 deletions.
27 changes: 18 additions & 9 deletions server/src/Core/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { debugLog } from "@/Helpers/Console";
import { execSimple, GetRunningProcesses } from "@/Helpers/Execute";
import { is_docker } from "@/Helpers/System";
import { isNumber } from "@/Helpers/Types";
import { TwitchHelper } from "@/Providers/Twitch";
import { YouTubeHelper } from "@/Providers/YouTube";
import type { SettingField } from "@common/Config";
import { settingsFields } from "@common/ServerConfig";
import type { AxiosResponse } from "axios";
Expand All @@ -13,8 +15,6 @@ import minimist from "minimist";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { TwitchHelper } from "@/Providers/Twitch";
import { YouTubeHelper } from "@/Providers/YouTube";
import {
AppRoot,
BaseConfigCacheFolder,
Expand Down Expand Up @@ -572,6 +572,15 @@ export class Config {
// no blocks in testing
// if (process.env.NODE_ENV === "test") return;

if (Config.getInstance().cfg("storage.no_watch_files", false)) {
log(
LOGLEVEL.DEBUG,
"config.startWatchingConfig",
`Not watching config file due to 'storage.no_watch_files' setting`
);
return false;
}

// monitor config for external changes
this.watcher = fs.watch(
BaseConfigPath.config,
Expand Down Expand Up @@ -634,7 +643,7 @@ export class Config {
console.log(
chalk.green(
"Client is built: " +
path.join(BaseConfigFolder.client, "index.html")
path.join(BaseConfigFolder.client, "index.html")
)
);
}
Expand Down Expand Up @@ -680,12 +689,12 @@ export class Config {
console.log(
chalk.green(
"Chat dumper is built: " +
path.join(
AppRoot,
"twitch-chat-dumper",
"build",
"index.js"
)
path.join(
AppRoot,
"twitch-chat-dumper",
"build",
"index.js"
)
)
);
}
Expand Down
9 changes: 9 additions & 0 deletions server/src/Core/Providers/Twitch/TwitchChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3124,6 +3124,15 @@ export class TwitchChannel extends BaseChannel {
return false; // don't watch if no channel folders are enabled
}

if (Config.getInstance().cfg("storage.no_watch_files", false)) {
log(
LOGLEVEL.DEBUG,
"tw.channel.startWatching",
`Not watching files for ${this.internalName} due to setting being enabled`
);
return false;
}

const folders = [Helper.vodFolder(this.internalName)];

// if (this.login && fs.existsSync(path.join(BaseConfigDataFolder.saved_clips, "scheduler", this.login)))
Expand Down
9 changes: 9 additions & 0 deletions server/src/Core/Providers/Twitch/TwitchVOD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2868,6 +2868,15 @@ export class TwitchVOD extends BaseVOD {
// no blocks in testing
// if (process.env.NODE_ENV === "test") return false;

if (Config.getInstance().cfg("storage.no_watch_files", false)) {
log(
LOGLEVEL.DEBUG,
"vod.watch",
`Not watching files for ${this.basename} due to config setting`
);
return false;
}

const files = this.associatedFiles.map((f) =>
path.join(this.directory, f)
);
Expand Down
Loading

0 comments on commit 9f120ae

Please sign in to comment.