summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-07-07 17:39:52 -0400
committerDax Raad <[email protected]>2025-07-07 17:39:52 -0400
commit9948fcf1b6e6cea328085bdf3ad96ab05a139f52 (patch)
tree926a359615b049393fec4932332012fef2c97be0
parent0d50c867ff16686d47101fa6d29e07539fe40d8f (diff)
downloadopencode-9948fcf1b6e6cea328085bdf3ad96ab05a139f52.tar.gz
opencode-9948fcf1b6e6cea328085bdf3ad96ab05a139f52.zip
fix crash when running on new project
-rw-r--r--packages/opencode/src/storage/storage.ts30
1 files changed, 16 insertions, 14 deletions
diff --git a/packages/opencode/src/storage/storage.ts b/packages/opencode/src/storage/storage.ts
index ccafb34da..7093fb252 100644
--- a/packages/opencode/src/storage/storage.ts
+++ b/packages/opencode/src/storage/storage.ts
@@ -17,21 +17,23 @@ export namespace Storage {
const MIGRATIONS: Migration[] = [
async (dir: string) => {
- const files = new Bun.Glob("session/message/*/*.json").scanSync({
- cwd: dir,
- absolute: true,
- })
- for (const file of files) {
- const content = await Bun.file(file).json()
- if (!content.metadata) continue
- log.info("migrating to v2 message", { file })
- try {
- const result = MessageV2.fromV1(content)
- await Bun.write(file, JSON.stringify(result, null, 2))
- } catch (e) {
- await fs.rename(file, file.replace("storage", "broken"))
+ try {
+ const files = new Bun.Glob("session/message/*/*.json").scanSync({
+ cwd: dir,
+ absolute: true,
+ })
+ for (const file of files) {
+ const content = await Bun.file(file).json()
+ if (!content.metadata) continue
+ log.info("migrating to v2 message", { file })
+ try {
+ const result = MessageV2.fromV1(content)
+ await Bun.write(file, JSON.stringify(result, null, 2))
+ } catch (e) {
+ await fs.rename(file, file.replace("storage", "broken"))
+ }
}
- }
+ } catch {}
},
]