From 2921481d364ed6bb79153d9f71a1b3235666721f Mon Sep 17 00:00:00 2001 From: Apollo3zehn Date: Mon, 11 Sep 2023 10:59:53 +0200 Subject: [PATCH] Minor bug fix --- CHANGELOG.md | 4 +++ .../StructuredFileDataSource.cs | 26 +++++++++++++++++-- version.json | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f79f9c2..5fc27a9 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2.0.0-beta.9 - 2023-09-11 + +- Minor bug fix. + ## v2.0.0-beta.8 - 2023-09-11 - Do not catch OutOfMemory Exceptions. diff --git a/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs b/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs index 3f752f2..ea55642 100644 --- a/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs +++ b/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; using Nexus.DataModel; @@ -370,8 +371,29 @@ protected virtual async Task ReadAsync( var filePaths = await FindFilePathsAsync(currentBegin, fileSource); // determine file begin - if (!TryGetFileBeginByPath(filePaths.First(), fileSource, out var fileBegin, folderBegin: default)) - throw new Exception($"Unable to determine date/time of file {filePaths.First()}."); + DateTime fileBegin; + + if (filePaths.Any()) + { + if (!TryGetFileBeginByPath(filePaths.First(), fileSource, out fileBegin, folderBegin: default)) + throw new Exception($"Unable to determine date/time of file {filePaths.First()}."); + } + + else + { + // TODO: Test this code path + // determine begin of missing file + var localBegin = begin.Kind switch + { + DateTimeKind.Local => begin, + DateTimeKind.Utc => DateTime.SpecifyKind(begin.Add(fileSource.UtcOffset), DateTimeKind.Local), + _ => throw new ArgumentException("The begin parameter must have its kind property specified.") + }; + + var roundedLocalBegin = localBegin.RoundDown(fileSource.FilePeriod); + + fileBegin = AdjustToUtc(roundedLocalBegin, fileSource.UtcOffset); + } /* CB = Current Begin, FP = File Period * diff --git a/version.json b/version.json index 4ab5f6f..2ae005b 100755 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { "version": "2.0.0", - "suffix": "beta.8" + "suffix": "beta.9" } \ No newline at end of file