Skip to content

Commit 32ea057

Browse files
committed
fix user context data not migrated.
1 parent cad2c41 commit 32ea057

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/EIDEProjectMigration.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { EIDE_CONF_VERSION, ProjectConfiguration } from "./EIDETypeDefine";
66
import { compareVersion } from "./utility";
77
import { view_str$prompt$migrationFailed } from "./StringTable";
88
import { GlobalEvent } from "./GlobalEvents";
9+
import { getGlobalState } from "./Platform";
910

1011
export function detectProject(dir: File): boolean {
1112
if (File.IsExist(NodePath.join(dir.path, '.eide', 'eide.yml')))
@@ -73,8 +74,23 @@ async function _doMigration(projectRootDir: File) {
7374

7475
// rm .eide.usr.ctx.json
7576
const p = NodePath.join(projectRootDir.path, '.eide.usr.ctx.json');
76-
if (File.IsFile(p))
77-
try { fs.unlinkSync(p); } catch (error) {}
77+
if (File.IsFile(p)) {
78+
try {
79+
if (prjCfg.miscInfo && prjCfg.miscInfo.uid) {
80+
const ctx = JSON.parse(fs.readFileSync(p, 'utf8'));
81+
const key = `project.${prjCfg.miscInfo.uid}`;
82+
const val = getGlobalState().get<string>(key);
83+
const saveVal = JSON.stringify(ctx);
84+
if (val !== saveVal)
85+
getGlobalState().update(key, saveVal);
86+
}
87+
fs.unlinkSync(p);
88+
} catch (error) {
89+
const errMsg = `${(<Error>error).name} ${(<Error>error).message}`;
90+
GlobalEvent.log_warn(`Fail to migrate user context '${p}'. msg: ${errMsg}`);
91+
GlobalEvent.log_show();
92+
}
93+
}
7894
}
7995

8096
export async function doMigration(projectRootDir: File) {

0 commit comments

Comments
 (0)