CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
111 lines
4.7 KiB
C#
111 lines
4.7 KiB
C#
using Chronos.Core.Diagnostics;
|
|
using Chronos.Core.Imaging;
|
|
using Chronos.Core.Metadata.Bmff;
|
|
using Chronos.Core.Metadata.Jpeg;
|
|
using Chronos.Core.Metadata.Png;
|
|
using Chronos.Core.Metadata.Raf;
|
|
using Chronos.Core.Metadata.Riff;
|
|
using Chronos.Core.Metadata.Tiff;
|
|
|
|
namespace Chronos.Core.Metadata;
|
|
|
|
/// <summary>
|
|
/// Reads <see cref="FrameMetadata"/> from any supported photo (BRIEF §9). Detects the container by signature, then
|
|
/// reads only the structures it needs through bounded seeks (a RAW's image data is never read). Malformed input never
|
|
/// throws: the result carries whatever was readable plus <see cref="FrameMetadata.Warnings"/>.
|
|
/// </summary>
|
|
public static class MetadataReader
|
|
{
|
|
private const string LogCategory = "Metadata";
|
|
private const int FileBufferSize = 4096;
|
|
|
|
/// <summary>Reads the file at <paramref name="path"/>; its modification time is the last-resort capture time.</summary>
|
|
/// <exception cref="IOException">The file cannot be opened (missing or locked).</exception>
|
|
/// <exception cref="UnauthorizedAccessException">Access to the file is denied.</exception>
|
|
public static FrameMetadata Read(string path, CancellationToken cancellationToken = default)
|
|
{
|
|
ArgumentException.ThrowIfNullOrEmpty(path);
|
|
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete, FileBufferSize, FileOptions.RandomAccess);
|
|
return Read(stream, Path.GetFileName(path), File.GetLastWriteTime(path), cancellationToken);
|
|
}
|
|
|
|
/// <summary>Reads metadata from a readable, seekable stream (the position is left undefined).</summary>
|
|
/// <param name="fileName">Name used only to break signature ties (see <see cref="ImageSignature"/>).</param>
|
|
/// <param name="fileModifiedLocal">File time used when no capture time is recorded (<see cref="Model.TimestampSource.FileSystem"/>);
|
|
/// its UTC offset is taken from the local zone for <see cref="DateTimeKind.Local"/> values.</param>
|
|
/// <exception cref="OperationCanceledException">Cancelled through <paramref name="cancellationToken"/>.</exception>
|
|
public static FrameMetadata Read(Stream stream, string? fileName, DateTime? fileModifiedLocal = null, CancellationToken cancellationToken = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(stream);
|
|
if (!stream.CanSeek || !stream.CanRead) throw new ArgumentException("The stream must be readable and seekable.", nameof(stream));
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
var m = new MetadataBuilder(stream, cancellationToken);
|
|
try
|
|
{
|
|
m.Format = ImageSignature.Detect(stream, fileName);
|
|
Parse(m);
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (IOException ex)
|
|
{
|
|
m.Warn("I/O error: " + ex.Message);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// Safety net: parsers are written not to throw, but a defect must cost one file's metadata, not the import.
|
|
m.Warn($"Parser fault: {ex.GetType().Name}: {ex.Message}");
|
|
Log.Warning(LogCategory, $"Metadata parser fault in {fileName ?? "stream"}", ex);
|
|
}
|
|
return m.Build(fileModifiedLocal);
|
|
}
|
|
|
|
private static void Parse(MetadataBuilder m)
|
|
{
|
|
switch (m.Format)
|
|
{
|
|
case ImageFileFormat.Jpeg:
|
|
JpegParser.Parse(m, 0, m.Length, primary: true);
|
|
break;
|
|
case ImageFileFormat.Png:
|
|
PngParser.Parse(m);
|
|
break;
|
|
case ImageFileFormat.WebP:
|
|
WebPParser.Parse(m);
|
|
break;
|
|
case ImageFileFormat.Heif or ImageFileFormat.Avif:
|
|
HeifParser.Parse(m);
|
|
break;
|
|
case ImageFileFormat.Cr3:
|
|
Cr3Parser.Parse(m);
|
|
break;
|
|
case ImageFileFormat.Raf:
|
|
RafParser.Parse(m);
|
|
break;
|
|
case ImageFileFormat.Gif:
|
|
MinimalFormatParser.ParseGif(m);
|
|
break;
|
|
case ImageFileFormat.Bmp:
|
|
MinimalFormatParser.ParseBmp(m);
|
|
break;
|
|
case ImageFileFormat.JpegXr:
|
|
MinimalFormatParser.ParseJpegXr(m);
|
|
break;
|
|
case ImageFileFormat.JpegXl:
|
|
MinimalFormatParser.ParseJpegXl(m);
|
|
break;
|
|
case ImageFileFormat.Crw:
|
|
m.Warn("CRW (CIFF) metadata is not supported");
|
|
break;
|
|
case ImageFileFormat.Unknown:
|
|
m.Warn("Unrecognised file signature");
|
|
break;
|
|
default:
|
|
ExifParser.ParseFile(m);
|
|
break;
|
|
}
|
|
}
|
|
}
|