journal/Journal.Core/Repositories/DiskEntryFileRepository.cs
Jacob Schmidt d1e4989303 Add edit/delete buttons to SidePanel for all sections, custom entry filenames, vault persistence
- Add edit/delete icon buttons to SidePanel items for entries, todos, lists, and fragments
- Move fragment edit/delete controls from FragmentEditor main panel to SidePanel
- Add externalEditRequested prop to FragmentEditor for parent-controlled edit mode
- Add fragment delete handling in +page.svelte performDelete flow
- Support custom entry filenames via FileName parameter in EntrySavePayload
- Fix vault persistence for custom-named entries (non-date-formatted .md files)
- Add VaultStorageService SaveCustomEntries helper for _custom_entries.vault
- Add entries.delete backend command and wire through EntryFileService
- Remove Write/Preview toggle from MarkdownEditor (previewOnly controlled by parent)
- Add smoke tests for vault custom entry roundtrip and entry save with custom filename

Co-Authored-By: Oz <oz-agent@warp.dev>
2026-02-26 19:40:43 -06:00

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)];
}
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);
}
public void DeleteFile(string filePath) => File.Delete(filePath);
}