refactor(uploader): drop members only tests used
Tests write serialized queue and watch-memory bytes directly; the app persists through its coalescing writer. Single-instance hand-over no longer returns an unused flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
8 files changed
+8
-24
No files matched your search
@@ -64,7 +64,7 @@ public partial class App : Application
|
||||
_instance = SingleInstance.TryAcquire();
|
||||
if (_instance is null)
|
||||
{
|
||||
SingleInstance.TrySend([.. command.Paths.Select(Absolute).OfType<string>()]);
|
||||
SingleInstance.HandOver([.. command.Paths.Select(Absolute).OfType<string>()]);
|
||||
Log.Info("app", "Another uploader runs in this session; arguments handed over");
|
||||
Shutdown();
|
||||
return;
|
||||
|
||||
@@ -33,7 +33,7 @@ public sealed class SingleInstance : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>Sends <paramref name="args"/> (absolute paths; empty = just show the window) to the running instance.</summary>
|
||||
public static bool TrySend(IReadOnlyList<string> args)
|
||||
public static void HandOver(IReadOnlyList<string> args)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -41,12 +41,10 @@ public sealed class SingleInstance : IDisposable
|
||||
pipe.Connect(3000);
|
||||
pipe.Write(Encode(args));
|
||||
pipe.Flush();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or TimeoutException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("instance", "Could not reach the running uploader", ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,7 @@ using Titano.Protocol;
|
||||
namespace Titano.Uploader.Server;
|
||||
|
||||
/// <summary>A Titano Server announced on the LAN.</summary>
|
||||
public sealed record DiscoveredServer(string Name, string Address)
|
||||
{
|
||||
public override string ToString() => Name + " · " + Address;
|
||||
}
|
||||
public sealed record DiscoveredServer(string Name, string Address);
|
||||
|
||||
/// <summary>
|
||||
/// Listens for the server's UDP beacon (<see cref="DiscoveryBeacon.Port"/>) while the connect form is open and reports
|
||||
@@ -31,17 +28,15 @@ public sealed class DiscoveryListener : IDisposable
|
||||
_ = Task.Run(() => ListenAsync(context, _cts.Token));
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
public void Dispose()
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts?.Dispose();
|
||||
_cts = null;
|
||||
}
|
||||
|
||||
public void Dispose() => Stop();
|
||||
|
||||
/// <summary>The address the client should use for <paramref name="beacon"/> sent from <paramref name="sender"/>.</summary>
|
||||
public static string AddressOf(DiscoveryBeacon beacon, IPAddress sender)
|
||||
private static string AddressOf(DiscoveryBeacon beacon, IPAddress sender)
|
||||
{
|
||||
var host = sender.AddressFamily == AddressFamily.InterNetworkV6 ? "[" + sender + "]" : sender.ToString();
|
||||
return beacon.HttpsPort > 0 ? $"https://{host}:{beacon.HttpsPort}" : $"http://{host}:{beacon.HttpPort}";
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.IO;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.IO;
|
||||
|
||||
namespace Titano.Uploader.Uploads;
|
||||
|
||||
@@ -73,9 +72,6 @@ public static class QueueStore
|
||||
file.Paused);
|
||||
}
|
||||
|
||||
/// <summary>Commits serialized bytes with temp → fsync → rename.</summary>
|
||||
public static void Write(string path, byte[] content) => AtomicFile.WriteAllBytes(path, content);
|
||||
|
||||
internal sealed class QueueFile
|
||||
{
|
||||
public int Version { get; set; }
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.IO;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.IO;
|
||||
using Titano.Uploader.Sources;
|
||||
|
||||
namespace Titano.Uploader.Watching;
|
||||
@@ -106,8 +105,6 @@ public sealed class ProcessedFileMemory
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(string path) => AtomicFile.WriteAllBytes(path, Serialize());
|
||||
|
||||
/// <summary>Loads <paramref name="path"/>; a missing or corrupt file gives an empty memory.</summary>
|
||||
public static ProcessedFileMemory Load(string path)
|
||||
{
|
||||
|
||||
@@ -44,6 +44,4 @@ public sealed class StableFileTracker
|
||||
_seen[o.Path] = (o.Size, o.ModifiedUtc, count);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Clear() => _seen.Clear();
|
||||
}
|
||||
Reference in new issue
Block a user