Skip to content

Commit

Permalink
Merge pull request #150 from hrntsm/fix/log-file-access-error
Browse files Browse the repository at this point in the history
Fix file access error
  • Loading branch information
hrntsm authored Mar 7, 2023
2 parents 620cb71 + ccdb5e2 commit d2f07ce
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Tunny/Storage/JournalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ public StudySummary[] GetStudySummaries(string storagePath)
return Array.Empty<StudySummary>();
}
var journalStorageString = new List<string>();
foreach (string line in File.ReadLines(storagePath))
using (FileStream fs = File.Open(storagePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
journalStorageString.Add(line);
using (var sr = new StreamReader(fs))
{
while (sr.Peek() >= 0)
{
journalStorageString.Add(sr.ReadLine());
}
}
}

JournalStorage[] storage = Deserialize(journalStorageString);
var studyName = storage.Where(x => x.OpCode == 0).Select(x => x.StudyName).Distinct().ToList();
IEnumerable<IGrouping<int?, JournalStorage>> userAttr = storage.Where(x => x.OpCode == 2)
Expand Down

0 comments on commit d2f07ce

Please sign in to comment.