Skip to content

Commit 33fb678

Browse files
committed
đź”§ Fix(SyncCodes): Some error in HTTP return type and differences comparison
1 parent 4708834 commit 33fb678

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

‎Utils/SyncCodes/Program.cs

+11-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Text.Json;
33
using System.Text.RegularExpressions;
44
using CommandLine;
5-
using Polly;
65
using Spectre.Console;
76
using SyncCodes;
87
using Context = SyncCodes.Context;
@@ -141,9 +140,6 @@ await catalogResponse.Content.ReadAsStringAsync(),
141140

142141
var localCatalog = context.GetFiles();
143142

144-
// app.Logger.LogInformation("Remote catalog: {json}", JsonSerializer.Serialize(catalog, jsonSerializerOptions));
145-
// app.Logger.LogInformation("Local catalog: {json}", JsonSerializer.Serialize(localCatalog, jsonSerializerOptions));
146-
147143
var differences = catalog.Concat(localCatalog).GroupBy(
148144
f => f.Path.RelatedTo(workBase),
149145
f => f.Hash,
@@ -156,20 +152,9 @@ await catalogResponse.Content.ReadAsStringAsync(),
156152
}
157153
);
158154

159-
// var toDelete = differences.Where(c => c.LocalHash is not null && c.RemoteHash is null).ToList();
160-
// var toDownload = differences.Where(c => c.LocalHash is null && c.RemoteHash is not null).ToList();
161-
// var toUpdate = differences.Where(c => c.LocalHash is not null && c.RemoteHash is not null && !c.LocalHash.Equals(c.RemoteHash));
162-
//
163-
// app.Logger.LogInformation(
164-
// "Remote: {json1}\n Local: {json2}\n Differences: {json3}",
165-
// JsonSerializer.Serialize(toDelete, jsonSerializerOptions),
166-
// JsonSerializer.Serialize(toDownload, jsonSerializerOptions),
167-
// JsonSerializer.Serialize(toUpdate, jsonSerializerOptions)
168-
// );
169-
170155
foreach (var comparison in differences)
171156
{
172-
if (comparison.LocalHash is not null && comparison.RemoteHash is not null)
157+
if (comparison.LocalHash is not null && comparison.RemoteHash is null)
173158
{
174159
var filePath = Path.Combine(workBase, comparison.Path);
175160
if (!File.Exists(filePath))
@@ -212,11 +197,16 @@ await catalogResponse.Content.ReadAsStringAsync(),
212197

213198
app.MapGet(
214199
"/",
215-
() => HomePageHtml(
216-
subTitle: "Development usage only (Client Mode)",
217-
content: $"""
218-
<p class="mt-4 text-xl text-gray-500">🌏 Target Server Address: <a href="{address}" target="_blank" class="font-semibold text-indigo-600 underline">{address}</a></p>
219-
"""
200+
() => Results.Content(
201+
HomePageHtml(
202+
subTitle: "Development usage only (Client Mode)",
203+
content: $"""
204+
<p class="mt-4 text-xl text-gray-500">🌏 Target Server Address: <a href="{address}" target="_blank" class="font-semibold text-indigo-600 underline">{address}</a></p>
205+
<p class="mt-4 text-xl text-gray-500">đź“‚ Work Base Path: <a href="file:///{workBase}" target="_blank" class="font-semibold text-indigo-600 underline">{workBase}</a></p>
206+
"""
207+
),
208+
"text/html",
209+
Encoding.UTF8
220210
)
221211
);
222212

0 commit comments

Comments
 (0)