refactor(shared): consolidate 13+ getMessageDir copies into single shared function
This commit is contained in:
+1
-15
@@ -3,6 +3,7 @@ import { join } from "node:path"
|
||||
import { getOpenCodeStorageDir } from "../../shared/data-path"
|
||||
import { truncateToolResult } from "./storage"
|
||||
import { log } from "../../shared/logger"
|
||||
import { getMessageDir } from "../../shared/opencode-message-dir"
|
||||
|
||||
interface StoredToolPart {
|
||||
type?: string
|
||||
@@ -21,21 +22,6 @@ function getPartStorage(): string {
|
||||
return join(getOpenCodeStorageDir(), "part")
|
||||
}
|
||||
|
||||
function getMessageDir(sessionID: string): string | null {
|
||||
const messageStorage = getMessageStorage()
|
||||
if (!existsSync(messageStorage)) return null
|
||||
|
||||
const directPath = join(messageStorage, sessionID)
|
||||
if (existsSync(directPath)) return directPath
|
||||
|
||||
for (const dir of readdirSync(messageStorage)) {
|
||||
const sessionPath = join(messageStorage, dir, sessionID)
|
||||
if (existsSync(sessionPath)) return sessionPath
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function getMessageIds(sessionID: string): string[] {
|
||||
const messageDir = getMessageDir(sessionID)
|
||||
if (!messageDir) return []
|
||||
|
||||
Reference in New Issue
Block a user