Skip to content

Commit 8f41319

Browse files
authored
Merge pull request #637 from CodinGame/fix-overlay-fs
fix(overlayfs): mkdirp on all write requests
2 parents 1823344 + 21d5420 commit 8f41319

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/service-override/files.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ class OverlayFileSystemProvider
792792
}
793793

794794
private async writeToDelegates(
795+
resource: URI,
795796
caller: (delegate: IFileSystemProviderWithFileReadWriteCapability) => Promise<void>
796797
): Promise<void> {
797798
if (this.delegates.length === 0) {
@@ -802,6 +803,7 @@ class OverlayFileSystemProvider
802803
continue
803804
}
804805
try {
806+
await mkdirp(extUri, provider, extUri.dirname(resource))
805807
return await caller(provider)
806808
} catch (err) {
807809
if (
@@ -911,7 +913,7 @@ class OverlayFileSystemProvider
911913
}
912914

913915
async writeFile(resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise<void> {
914-
await this.writeToDelegates(async (delegate) => {
916+
await this.writeToDelegates(resource, async (delegate) => {
915917
let stats: IStat | undefined
916918
try {
917919
stats = await delegate.stat(resource)
@@ -929,15 +931,15 @@ class OverlayFileSystemProvider
929931
}
930932

931933
async mkdir(resource: URI): Promise<void> {
932-
await this.writeToDelegates((delegate) => delegate.mkdir(resource))
934+
await this.writeToDelegates(resource, (delegate) => delegate.mkdir(resource))
933935
}
934936

935937
async delete(resource: URI, opts: IFileDeleteOptions): Promise<void> {
936-
await this.writeToDelegates((delegate) => delegate.delete(resource, opts))
938+
await this.writeToDelegates(resource, (delegate) => delegate.delete(resource, opts))
937939
}
938940

939941
async rename(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> {
940-
await this.writeToDelegates((delegate) => delegate.rename(from, to, opts))
942+
await this.writeToDelegates(to, (delegate) => delegate.rename(from, to, opts))
941943
}
942944
}
943945

0 commit comments

Comments
 (0)