ClassicStorageProvider will now being used as much as possible to support setting output directory to anywhere.

This commit is contained in:
Creeper Lv
2026-03-23 00:34:18 +11:00
parent 2b42f43b6e
commit d7f2391fe8
3 changed files with 36 additions and 5 deletions
+19 -4
View File
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Diagnostics;
using Newtonsoft.Json;
using Progrart.Core.JSExecution;
using Progrart.Core.Storage;
@@ -33,7 +34,14 @@ namespace Progrart.Core.ProjectSystem
return;
using var reader = new StreamReader(stream);
var img = executor.RenderImage(item.Size, reader.ReadToEnd(), args);
var outputFile= Path.Combine(project.OutputDir, item.Target ?? item.Source + ".png");
string outputFile;
if (config.OutputDir != null)
outputFile = Path.Combine(project.OutputDir, config.OutputDir ?? "", item.Target ?? item.Source + ".png");
else
{
outputFile = Path.Combine(project.OutputDir, item.Target ?? item.Source + ".png");
}
using var img_stream = await provider.TryOpenWrite(outputFile);
if (img_stream is null)
return;
@@ -42,7 +50,7 @@ namespace Progrart.Core.ProjectSystem
}
public async Task Build(string targetConfig, int maxJobCount = 1)
{
int finalJobCount= Math.Max(maxJobCount < 0 ? Environment.ProcessorCount : maxJobCount, 1);
int finalJobCount = Math.Max(maxJobCount < 0 ? Environment.ProcessorCount : maxJobCount, 1);
foreach (var config in project.Configurations)
{
if (config.Name == targetConfig)
@@ -67,7 +75,14 @@ namespace Progrart.Core.ProjectSystem
await Parallel.ForEachAsync(config.Items, options, async (item, token) =>
{
await Execute(config, item);
try
{
await Execute(config, item);
}
catch (Exception e)
{
Trace.WriteLine(e);
}
int currentCount = Interlocked.Increment(ref index);
OnProgressUpdate?.Invoke(config.Items.Count, currentCount);