Skip to content

Commit 57518c5

Browse files
Ensure we dispose of temporary FileSystemHandleInProcess.
1 parent aa04963 commit 57518c5

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ protected FileSystemDirectoryHandleInProcess(IJSRuntime jSRuntime, IJSInProcessO
5555
.Range(0, length)
5656
.Select<int, Task<IFileSystemHandleInProcess>>(async i =>
5757
{
58-
FileSystemHandleInProcess fileSystemHandle = await FileSystemHandleInProcess.CreateAsync(
58+
await using FileSystemHandleInProcess fileSystemHandle = await FileSystemHandleInProcess.CreateAsync(
5959
JSRuntime,
60-
await jSEntries.InvokeAsync<IJSInProcessObjectReference>("at", i)
60+
await jSEntries.InvokeAsync<IJSInProcessObjectReference>("at", i),
61+
new()
62+
{
63+
DisposesJSReference = false // We explicitly show that we don't expose the reference as it is used later.
64+
}
6165
);
6266

6367
FileSystemHandleKind kind = await fileSystemHandle.GetKindAsync();

src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public async Task<IFileSystemHandle[]> ValuesAsync()
4848
{
4949
await using FileSystemHandle fileSystemHandle = await FileSystemHandle.CreateAsync(
5050
JSRuntime,
51-
await jSEntries.InvokeAsync<IJSObjectReference>("at", i)
51+
await jSEntries.InvokeAsync<IJSObjectReference>("at", i),
52+
new()
53+
{
54+
DisposesJSReference = false // We explicitly show that we don't expose the reference as it is used later.
55+
}
5256
);
5357

5458
FileSystemHandleKind kind = await fileSystemHandle.GetKindAsync();

0 commit comments

Comments
 (0)