feat(cleaner): compute videoDir and pass through to ErpAuthService
Add ensureVideoDir helper that creates <logDir>/video/ directory on demand. Pass recordVideo and videoDir to both ErpAuthService instantiations (initial login and outer retry) in cleaner-application-service. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import path from 'path'
|
||||||
|
import fs from 'fs'
|
||||||
import type { WebContents } from 'electron'
|
import type { WebContents } from 'electron'
|
||||||
import type { IDatabaseService } from '../../types/database.types'
|
import type { IDatabaseService } from '../../types/database.types'
|
||||||
import { ErpAuthService } from '../erp/erp-auth'
|
import { ErpAuthService } from '../erp/erp-auth'
|
||||||
@@ -11,6 +13,7 @@ import { ResultExporter } from '../excel/result-exporter'
|
|||||||
import { SessionManager } from '../user/session-manager'
|
import { SessionManager } from '../user/session-manager'
|
||||||
import { UserErpConfigService } from '../user/user-erp-config-service'
|
import { UserErpConfigService } from '../user/user-erp-config-service'
|
||||||
import { createLogger } from '../logger'
|
import { createLogger } from '../logger'
|
||||||
|
import { getLogDir } from '../logger/shared'
|
||||||
import { logAuditWithCurrentUser } from '../logger/audit-logger'
|
import { logAuditWithCurrentUser } from '../logger/audit-logger'
|
||||||
import { AuditAction, AuditStatus } from '../../types/audit.types'
|
import { AuditAction, AuditStatus } from '../../types/audit.types'
|
||||||
import { IPC_CHANNELS } from '../../../shared/ipc-channels'
|
import { IPC_CHANNELS } from '../../../shared/ipc-channels'
|
||||||
@@ -128,11 +131,15 @@ export class CleanerApplicationService {
|
|||||||
return emptyResult
|
return emptyResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const videoDir = input.recordVideo ? this.ensureVideoDir() : undefined
|
||||||
|
|
||||||
authService = new ErpAuthService({
|
authService = new ErpAuthService({
|
||||||
url: erpConfig.url,
|
url: erpConfig.url,
|
||||||
username: erpConfig.username,
|
username: erpConfig.username,
|
||||||
password: erpConfig.password,
|
password: erpConfig.password,
|
||||||
headless: input.headless ?? true
|
headless: input.headless ?? true,
|
||||||
|
recordVideo: input.recordVideo ?? false,
|
||||||
|
videoDir
|
||||||
})
|
})
|
||||||
|
|
||||||
log.info('Logging in to ERP...')
|
log.info('Logging in to ERP...')
|
||||||
@@ -200,7 +207,9 @@ export class CleanerApplicationService {
|
|||||||
url: erpConfig.url,
|
url: erpConfig.url,
|
||||||
username: erpConfig.username,
|
username: erpConfig.username,
|
||||||
password: erpConfig.password,
|
password: erpConfig.password,
|
||||||
headless: input.headless ?? true
|
headless: input.headless ?? true,
|
||||||
|
recordVideo: input.recordVideo ?? false,
|
||||||
|
videoDir
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -333,6 +342,14 @@ export class CleanerApplicationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ensureVideoDir(): string | undefined {
|
||||||
|
const videoDir = path.join(getLogDir(), 'video')
|
||||||
|
if (!fs.existsSync(videoDir)) {
|
||||||
|
fs.mkdirSync(videoDir, { recursive: true })
|
||||||
|
}
|
||||||
|
return videoDir
|
||||||
|
}
|
||||||
|
|
||||||
private async getDatabaseService(): Promise<IDatabaseService> {
|
private async getDatabaseService(): Promise<IDatabaseService> {
|
||||||
const configManager = ConfigManager.getInstance()
|
const configManager = ConfigManager.getInstance()
|
||||||
const config = configManager.getConfig()
|
const config = configManager.getConfig()
|
||||||
|
|||||||
Reference in New Issue
Block a user