Skip to content

Commit

Permalink
Don't keep file streams open (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarne authored Mar 1, 2024
1 parent 8ed54a8 commit 189d19d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Services/Storage/Implementation/DataRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private string GetDataCollectionFolder()

private static async Task<string> ReadFileAsString(string path)
{
Stream stream = await ReadFileAsStream(path);
using Stream stream = await ReadFileAsStream(path);
using StreamReader reader = new StreamReader(stream);
return await reader.ReadToEndAsync();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Storage/Implementation/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Task StartFileScan(Instance instance, DataType dataType, DataElement data
return (null, new ServiceError(404, $"DataElement not found, dataElementId: {dataElementId}"));
}

Stream filestream = await _dataRepository.ReadDataFromStorage(org, dataElement.BlobStoragePath);
using Stream filestream = await _dataRepository.ReadDataFromStorage(org, dataElement.BlobStoragePath);
if (filestream == null || !filestream.CanRead)
{
return (null, new ServiceError(404, $"Failed reading file, dataElementId: {dataElementId}"));
Expand Down

0 comments on commit 189d19d

Please sign in to comment.