mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
refactor: inline trivial single-use helpers
This commit is contained in:
1 parent
b002fbebec
commit
73dca90a51
19 files changed
+23
-113
No files matched your search
@@ -11,8 +11,3 @@ export interface IpcContext {
|
||||
/** 主窗口 */
|
||||
win: BrowserWindow
|
||||
}
|
||||
|
||||
/**
|
||||
* IPC 处理器注册函数类型
|
||||
*/
|
||||
export type IpcHandlerRegister = (ctx: IpcContext) => void
|
||||
@@ -7,7 +7,6 @@ import * as fs from 'node:fs'
|
||||
import * as path from 'node:path'
|
||||
import { loadConfig, writeConfigField } from '@openchatlab/config'
|
||||
import { arePathsOverlapping, copyDirMerge, copyDirRecursive, writeMigrationLog } from '../utils/pathUtils'
|
||||
import { shouldMarkUnifiedDirMigrationDone } from '../utils/unifiedDirMigration'
|
||||
import {
|
||||
ensureDir,
|
||||
getDefaultUserDataDir,
|
||||
@@ -363,7 +362,7 @@ export function migrateToUnifiedDirs(): { success: boolean; error?: string } {
|
||||
writeMigrationLog(getLogsDir(), summary, ensureDir)
|
||||
console.log(`[Migration] ${summary}`)
|
||||
|
||||
if (shouldMarkUnifiedDirMigrationDone(failedDirs)) {
|
||||
if (failedDirs.length === 0) {
|
||||
writeConfigField('data', 'electron_migration_done', true)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { shouldMarkUnifiedDirMigrationDone } from './unifiedDirMigration'
|
||||
|
||||
describe('desktop unified directory migration', () => {
|
||||
it('marks migration done only when no directory failed', () => {
|
||||
assert.equal(shouldMarkUnifiedDirMigrationDone([]), true)
|
||||
assert.equal(shouldMarkUnifiedDirMigrationDone(['settings']), false)
|
||||
})
|
||||
})
|
||||
@@ -1,3 +0,0 @@
|
||||
export function shouldMarkUnifiedDirMigrationDone(failedDirs: string[]): boolean {
|
||||
return failedDirs.length === 0
|
||||
}
|
||||
Reference in new issue
Block a user