- Slim Entry.cs from ~550 to ~330 lines (thin dispatcher only) - Extract HtmlSanitizer, CommandLogger, EntryFileService from Entry.cs - Extract PythonSidecarClient from duplicated sidecar plumbing - Add IEntryFileRepository + DiskEntryFileRepository (mirrors Fragment pattern) - Move payload records to Dtos/CommandDtos.cs - Move database result records to Dtos/DatabaseDtos.cs - Register new services and repository in DI - All 70/70 smoke tests pass, no behavior changes Co-Authored-By: Warp <agent@warp.dev>
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
namespace Journal.Core.Repositories;
|
|
|
|
public sealed class DiskEntryFileRepository : IEntryFileRepository
|
|
{
|
|
public IReadOnlyList<string> ListMarkdownFiles(string dataDirectory)
|
|
{
|
|
if (!Directory.Exists(dataDirectory))
|
|
return [];
|
|
|
|
return Directory.GetFiles(dataDirectory, "*.md")
|
|
.OrderBy(Path.GetFileName, StringComparer.Ordinal)
|
|
.ToArray();
|
|
}
|
|
|
|
public string ReadFile(string filePath) => File.ReadAllText(filePath);
|
|
|
|
public void WriteFile(string filePath, string content) => File.WriteAllText(filePath, content);
|
|
|
|
public void AppendFile(string filePath, string content) => File.AppendAllText(filePath, content);
|
|
|
|
public bool FileExists(string filePath) => File.Exists(filePath);
|
|
|
|
public string GetFullPath(string filePath) => Path.GetFullPath(filePath);
|
|
|
|
public string GetFileName(string filePath) => Path.GetFileName(filePath);
|
|
|
|
public string GetFileNameWithoutExtension(string filePath) => Path.GetFileNameWithoutExtension(filePath);
|
|
|
|
public void EnsureDirectory(string path)
|
|
{
|
|
var dir = Path.GetDirectoryName(path);
|
|
if (!string.IsNullOrWhiteSpace(dir))
|
|
Directory.CreateDirectory(dir);
|
|
}
|
|
}
|