From 6692ba1d44564a0d438c4d419d0c191c61eba468 Mon Sep 17 00:00:00 2001 From: Andreas Kellermann Date: Sat, 5 Oct 2024 07:37:51 +0200 Subject: [PATCH] fixed newestdatapoint file access if there are sorted and unsorted files (_ before #) --- FKala.Core/DataLayer/DataLayer_Readable_Caching_V1.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FKala.Core/DataLayer/DataLayer_Readable_Caching_V1.cs b/FKala.Core/DataLayer/DataLayer_Readable_Caching_V1.cs index 7b148dc..b5762c3 100644 --- a/FKala.Core/DataLayer/DataLayer_Readable_Caching_V1.cs +++ b/FKala.Core/DataLayer/DataLayer_Readable_Caching_V1.cs @@ -21,6 +21,7 @@ namespace FKala.Core { public class DataLayer_Readable_Caching_V1 : IDataLayer, IDisposable { + private readonly int FilenameDatePatternLength = "yyyy.MM.dd.dat".Length; public int ReadBuffer { get; } = 131072; public int WriteBuffer { get; } = 131072; @@ -105,7 +106,7 @@ public List LoadAvailableYears(string measurement) { var month = int.Parse(Path.GetFileName(monthDir)); - foreach (var file in Directory.GetFiles(monthDir, $"{measurementSubPath}*.dat").OrderDescending()) + foreach (var file in Directory.GetFiles(monthDir, $"{measurementSubPath}*.dat").OrderByDescending(fn => fn.Substring(fn.Length - FilenameDatePatternLength))) { var lastLine = LastLineReader.ReadLastLine(file); if (string.IsNullOrEmpty(lastLine))