()
| 330 | } |
| 331 | |
| 332 | saveConfig() { |
| 333 | // Create a copy of the config to save |
| 334 | const configToSave = { ...this.config }; |
| 335 | |
| 336 | // Deprecated -- remove from saved config |
| 337 | delete configToSave.youtubeOutputDirectory; |
| 338 | |
| 339 | // Internal use only |
| 340 | delete configToSave.envAuthApplied; |
| 341 | |
| 342 | // Don't save Elfhosted temp download overrides to config file |
| 343 | if (this.isElfhostedPlatform()) { |
| 344 | delete configToSave.useTmpForDownloads; |
| 345 | delete configToSave.tmpFilePath; |
| 346 | } |
| 347 | |
| 348 | // Set flag to ignore file watcher events triggered by this save |
| 349 | this.isSaving = true; |
| 350 | const configContent = JSON.stringify(configToSave, null, 2); |
| 351 | this.lastConfigContent = configContent; |
| 352 | fs.writeFileSync(this.configPath, configContent, { mode: 0o640 }); |
| 353 | this.tightenConfigPermissions(); |
| 354 | |
| 355 | // Clear the flag after a short delay to account for fs.watch() firing |
| 356 | setTimeout(() => { |
| 357 | this.isSaving = false; |
| 358 | }, 200); |
| 359 | } |
| 360 | |
| 361 | // chmod fails with EPERM if the file is owned by a different UID (common on upgrades |
| 362 | // from older Youtarr versions). Best-effort only — the content is already saved. |
no test coverage detected