Extract a per-user background host so indexing can later run outside the window.

Keep the GUI as the index writer for now; mutex, named pipe, and opt-in logon autostart prepare Explorer.Host.exe without two SQLite writers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-24 17:10:49 +02:00
parent 9efb306979
commit 7c23bc2474
40 changed files with 1586 additions and 140 deletions

View File

@@ -0,0 +1,60 @@
using Explorer.Application;
using Explorer.Contracts;
using Explorer.Domain;
namespace Explorer.Application.Tests;
public class WorkbenchHostTests
{
[Fact]
public void Forwards_indexing_and_transfer_sessions()
{
var indexing = new FakeIndexing();
var transfers = new FakeTransfers();
IWorkbenchHost host = new WorkbenchHost(indexing, transfers);
Assert.Same(indexing, host.Indexing);
Assert.Same(transfers, host.Transfers);
host.Indexing.EnqueueFullScan(7);
host.Transfers.PauseAll();
Assert.Equal(7, indexing.FullScanId);
Assert.True(transfers.PausedAll);
}
private sealed class FakeIndexing : IIndexingHost
{
public long FullScanId { get; private set; }
public event EventHandler<ScanProgress>? ProgressChanged;
public void EnqueueFullScan(long sourceId) => FullScanId = sourceId;
public void EnqueueFolderScan(long sourceId, string pathRel) { }
public void EnqueueReconcile(long sourceId, string pathRel) { }
public void Cancel(long sourceId) { }
public void Raise() => ProgressChanged?.Invoke(this, new ScanProgress
{
SourceId = 1,
CurrentPath = "",
Status = ScanJobStatus.Running
});
}
private sealed class FakeTransfers : ITransferHost
{
public bool PausedAll { get; private set; }
public event EventHandler? Changed = delegate { };
public event EventHandler<TransferJob>? JobFinished = delegate { };
public bool IsPaused => PausedAll;
public IReadOnlyList<TransferJob> Snapshot() => [];
public void PauseAll() => PausedAll = true;
public void ResumeAll() => PausedAll = false;
public void Pause(long jobId) { }
public void Resume(long jobId) { }
public void Retry(long jobId) { }
public void Cancel(long jobId) { }
public void Dismiss(long jobId) { }
public void ClearFinished() { }
public bool MoveUp(long jobId) => false;
public bool MoveDown(long jobId) => false;
}
}