-
Notifications
You must be signed in to change notification settings - Fork 799
fix: move workspaces to Ganache/ui/workspaces
#5151
Conversation
…egacy data being migrated to here. Symlink workspaces from 'old' workspaces directory. Use fs.readdirSync along with 'withFileTypes' to avoid additional 'stat' call.
Ganache/ui/workspaces
return spawn("cmd.exe", ["/c", "mkdir", path.join(USERDATA_PATH, "workspaces")]) | ||
return spawn("cmd.exe", ["/c", "mkdir", path.join(USERDATA_PATH, "ui/workspaces")]) | ||
}) | ||
.then(()=> { | ||
return spawn("cmd.exe", ["/c", "mkdir", path.join(USERDATA_PATH, "default")]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This magic "spawn" logic is here to ensure that real directories are created (required to be able to execute "extras" [such as postgres] in correct context). It may be removed in a subsequent change.
…eting linked workspaces.
let workspaceDirectory; | ||
if (fse.lstatSync(this.workspaceDirectory).isSymbolicLink()) { | ||
workspaceDirectory = fse.readlinkSync(this.workspaceDirectory); | ||
fse.unlinkSync(this.workspaceDirectory); | ||
} else { | ||
workspaceDirectory = this.workspaceDirectory; | ||
} | ||
|
||
try { | ||
fse.removeSync(this.workspaceDirectory); | ||
fse.removeSync(workspaceDirectory); | ||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first glance this worried me, because we unlink and delete, but we're deleting the symlink, and the directory to which that symlink points.
…ng to symlink workspaces
if (flavor === "ethereum" || flavor === "filecoin") { | ||
// silently ignore any workspaces that aren't of a supported flavor | ||
const linkPath = join(newWorkspacesDirectory, legacyWorkspace.name); | ||
if (legacyWorkspace.isDirectory() && !await exists(linkPath)) { | ||
return symlink(fullPath, linkPath, "junction"); | ||
} | ||
} | ||
} catch { | ||
// silently ignore any workspaces that fail to link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now silently ignore any workspace that is not ethereum or filecoin, or that fails to parse.
This changes the workspaces directory to
<config>/Ganache/ui/workspaces
in anticipation of all Ganache-UI configuration data being migrated to the<config>Ganache/ui
directory. This means that previous versions of Ganache-UI will not have visibility to "new" workspaces.During the "migration" phase of startup, all workspaces in the "old" location will have symlinks created in the "new" location - meaning that "old" workspaces are available in the "new" version of Ganache-UI.
Deleting workspaces in either version of Ganache-UI will cause the workspace to be deleted for both.