- 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>
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)];
|
|
}
|
|
|
|
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);
|
|
}
|