ClassicStorageProvider will now being used as much as possible to support setting output directory to anywhere.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using System.Diagnostics;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Progrart.Core.JSExecution;
|
using Progrart.Core.JSExecution;
|
||||||
using Progrart.Core.Storage;
|
using Progrart.Core.Storage;
|
||||||
|
|
||||||
@@ -33,7 +34,14 @@ namespace Progrart.Core.ProjectSystem
|
|||||||
return;
|
return;
|
||||||
using var reader = new StreamReader(stream);
|
using var reader = new StreamReader(stream);
|
||||||
var img = executor.RenderImage(item.Size, reader.ReadToEnd(), args);
|
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);
|
using var img_stream = await provider.TryOpenWrite(outputFile);
|
||||||
if (img_stream is null)
|
if (img_stream is null)
|
||||||
return;
|
return;
|
||||||
@@ -66,8 +74,15 @@ namespace Progrart.Core.ProjectSystem
|
|||||||
};
|
};
|
||||||
|
|
||||||
await Parallel.ForEachAsync(config.Items, options, async (item, token) =>
|
await Parallel.ForEachAsync(config.Items, options, async (item, token) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await Execute(config, item);
|
await Execute(config, item);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Trace.WriteLine(e);
|
||||||
|
}
|
||||||
|
|
||||||
int currentCount = Interlocked.Increment(ref index);
|
int currentCount = Interlocked.Increment(ref index);
|
||||||
OnProgressUpdate?.Invoke(config.Items.Count, currentCount);
|
OnProgressUpdate?.Invoke(config.Items.Count, currentCount);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -35,6 +36,12 @@ namespace Progrart.Core.Storage
|
|||||||
{
|
{
|
||||||
return await file.OpenWriteAsync();
|
return await file.OpenWriteAsync();
|
||||||
}
|
}
|
||||||
|
var parentPath = Path.GetDirectoryName(path);
|
||||||
|
if (parentPath is not null)
|
||||||
|
if ((await baseFolder.GetFolderAsync(parentPath)) == null)
|
||||||
|
{
|
||||||
|
await baseFolder.CreateFolderAsync(parentPath);
|
||||||
|
}
|
||||||
file = await baseFolder.CreateFileAsync(path);
|
file = await baseFolder.CreateFileAsync(path);
|
||||||
if (file is not null)
|
if (file is not null)
|
||||||
return await file.OpenWriteAsync();
|
return await file.OpenWriteAsync();
|
||||||
|
|||||||
@@ -274,7 +274,16 @@ public partial class MainView : UserControl
|
|||||||
{
|
{
|
||||||
if (App.LoadedProject is not null)
|
if (App.LoadedProject is not null)
|
||||||
{
|
{
|
||||||
Builder builder = new Builder(App.LoadedProject, new AvaloniaStorageProvider(App.CurrentOpenFolder));
|
Builder builder;
|
||||||
|
|
||||||
|
var localPath = App.CurrentOpenFolder?.TryGetLocalPath();
|
||||||
|
if (localPath != null)
|
||||||
|
{
|
||||||
|
builder = new Builder(App.LoadedProject, new ClassicStorageProvider(new DirectoryInfo(localPath)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
builder = new Builder(App.LoadedProject, new AvaloniaStorageProvider(App.CurrentOpenFolder));
|
||||||
|
|
||||||
var config = App.LoadedProject.Configurations[ConfigBox.SelectedIndex];
|
var config = App.LoadedProject.Configurations[ConfigBox.SelectedIndex];
|
||||||
var name = config.Name;
|
var name = config.Name;
|
||||||
if (config is null) return;
|
if (config is null) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user