Skip to content

Actually create the file when using CustomFileStream.CreateFile()#121

Merged
ritchiecarroll merged 1 commit into
masterfrom
customfilestream-createfile
Dec 3, 2025
Merged

Actually create the file when using CustomFileStream.CreateFile()#121
ritchiecarroll merged 1 commit into
masterfrom
customfilestream-createfile

Conversation

@StephenCWills

Copy link
Copy Markdown
Member

Looking at commit 10c3444, it seems that the changes made to CustomFileStream in order to lazy-open files as needed has caused a bug in CustomFileStream.CreateFile(). The code in the CustomFileStream constructor expects the file to be created so that the file size can be retrieved from the file system. This causes the constructor to fail.

FileInfo fileInfo = new FileInfo(fileName);
m_length.Value = fileInfo.Length;

This creates a bug that manifests in some of the test code, such as the samples in:
https://github.com/GridProtectionAlliance/openHistorian/blob/master/Source/Documentation/SampleCode/openHistorian.Core.dll/Sample0%20-%20Write%20Archive%20Points.cs

This PR resolves the bug by restoring the call to the FileStream constructor that was removed in 10c3444. Unlike the code from before that commit, we must close the file stream immediately after creating the file because we won't be keeping it open for the lifetime of the CustomFileStream instance.

@StephenCWills StephenCWills force-pushed the customfilestream-createfile branch from 75f6b6a to 3500149 Compare December 2, 2025 20:26
@ritchiecarroll ritchiecarroll merged commit cb6027e into master Dec 3, 2025
4 checks passed
@ritchiecarroll ritchiecarroll deleted the customfilestream-createfile branch December 3, 2025 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants