Skip to content

Commit 8939b18

Browse files
committed
Redirect error text to Console.Error
1 parent 658fbd4 commit 8939b18

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

WarpTools/Commands/BaseCommand.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,19 @@ internal void IterateOverItems(WorkerWrapper[] workers, BaseOptions cli, Action<
107107
// write processed_items.json
108108
JsonArray ItemsJson = new JsonArray(ImmutableProcessed.Select(series => series.ToMiniJson(cli.Options.Filter.ParticlesSuffix)).ToArray());
109109
File.WriteAllText(JsonFilePath + $".{iitem}", ItemsJson.ToJsonString(new JsonSerializerOptions() { WriteIndented = true }));
110-
lock (workers)
111-
File.Move(JsonFilePath + $".{iitem}", JsonFilePath, true);
110+
111+
bool Success = false;
112+
Stopwatch Watch = Stopwatch.StartNew();
113+
while (!Success && Watch.ElapsedMilliseconds < 10_000)
114+
{
115+
try
116+
{
117+
lock (workers)
118+
File.Move(JsonFilePath + $".{iitem}", JsonFilePath, true);
119+
Success = true;
120+
}
121+
catch { }
122+
}
112123
}));
113124
}
114125
catch
@@ -119,9 +130,9 @@ internal void IterateOverItems(WorkerWrapper[] workers, BaseOptions cli, Action<
119130
lock (workers)
120131
{
121132
VirtualConsole.ClearLastLine();
122-
Console.WriteLine($"Failed to process {M.Path}, marked as unselected");
123-
Console.WriteLine($"Check logs in {LogDirectory} for more info.");
124-
Console.WriteLine("Use the change_selection WarpTool to reactivate this item if required.");
133+
Console.Error.WriteLine($"Failed to process {M.Path}, marked as unselected");
134+
Console.Error.WriteLine($"Check logs in {LogDirectory} for more info.");
135+
Console.Error.WriteLine("Use the change_selection WarpTool to reactivate this item if required.");
125136
NFailed++;
126137
}
127138
}

0 commit comments

Comments
 (0)