MCPcopy
hub / github.com/jvilk/BrowserFS / umount

Method umount

src/backend/MountableFileSystem.ts:114–133  ·  view source on GitHub ↗
(mountPoint: string)

Source from the content-addressed store, hash-verified

112 }
113
114 public umount(mountPoint: string): void {
115 if (mountPoint[0] !== '/') {
116 mountPoint = `/${mountPoint}`;
117 }
118 mountPoint = path.resolve(mountPoint);
119 if (!this.mntMap[mountPoint]) {
120 throw new ApiError(ErrorCode.EINVAL, "Mount point " + mountPoint + " is already unmounted.");
121 }
122 delete this.mntMap[mountPoint];
123 this.mountList.splice(this.mountList.indexOf(mountPoint), 1);
124
125 while (mountPoint !== '/') {
126 if (this.rootFs.readdirSync(mountPoint).length === 0) {
127 this.rootFs.rmdirSync(mountPoint);
128 mountPoint = path.dirname(mountPoint);
129 } else {
130 break;
131 }
132 }
133 }
134
135 /**
136 * Returns the file system that the path points to.

Callers 1

mounting.tsFile · 0.80

Calls 2

readdirSyncMethod · 0.65
rmdirSyncMethod · 0.65

Tested by

no test coverage detected