Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Sep 16, 2024
1 parent fcc7efd commit cf94dd7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ export function App() {
files,
workplaceState.canisters,
);
await container.container!.mount(bundle, { mountPoint: "user" });
await container.rm("user", { recursive: true, force: true });
await container.mkdir("user");
await container.mount(bundle, { mountPoint: "user" });
},
[workplaceDispatch],
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/FrontendDeployModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export function FrontendDeployModal({
state.files,
canisters,
);
await container.container!.mount(files, { mountPoint: "user" });
// mount doesn't remove old files, but this is fine for now
await container.mount(files, { mountPoint: "user" });
if (Object.keys(canisters).length === 0) {
logger.log(
"No backend canisters found. Please deploy at least one backend canister first.",
Expand Down
14 changes: 14 additions & 0 deletions src/webcontainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ export class Container {
};
await this.container!.mount(files);
}
async mount(files: FileSystemTree, options?: { mountPoint?: string }) {
await this.init();
if (this.isDummy) {
return;
}
await this.container!.mount(files, options);
}
async rm(path: string, options?: { recursive?: boolean; force?: boolean }) {
await this.init();
if (this.isDummy) {
return;
}
await this.container!.fs.rm(path, options);
}
async writeFile(
path: string,
contents: string | Uint8Array,
Expand Down

0 comments on commit cf94dd7

Please sign in to comment.