Skip to content

Commit 266d795

Browse files
Improve handling with file systems.
1 parent 625ba81 commit 266d795

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/IFileSystem.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public interface IFileSystem : IDisposable
1616

1717
bool CanWrite => true;
1818

19+
bool CanAccessInParallel => false;
20+
1921
IFile GetFile(FilePath path);
2022

2123
IEnumerable<IFile> GetFiles(FilePath path, string extension);

cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/FileSystem/Zip/ZipFileSystem.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public sealed class ZipFileSystem : IFileSystem
2020

2121
public string FullName => fileInfo.FullName;
2222

23+
public bool CanAccessInParallel => false;
24+
2325
public ZipFileSystem(FileInfo fileInfo)
2426
{
2527
zipArchive = new ZipArchive(fileInfo.Open(FileMode.OpenOrCreate), ZipArchiveMode.Update);

cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public DownloadPipeline(ISession session, ILogger log, IFileSystem fs)
5252
BoundedCapacity = 1
5353
});
5454

55+
var maxDegreeOfParallelism = fs.CanAccessInParallel ? Environment.ProcessorCount * 2 : 1;
56+
5557
var downloadStep = new ActionBlock<(AssetDto, FilePath)>(async item =>
5658
{
5759
var (asset, path) = item;
@@ -88,9 +90,9 @@ public DownloadPipeline(ISession session, ILogger log, IFileSystem fs)
8890
}
8991
}, new ExecutionDataflowBlockOptions
9092
{
91-
MaxDegreeOfParallelism = 8,
93+
MaxDegreeOfParallelism = maxDegreeOfParallelism,
9294
MaxMessagesPerTask = 1,
93-
BoundedCapacity = 16
95+
BoundedCapacity = maxDegreeOfParallelism * 2
9496
});
9597

9698
fileNameStep.LinkTo(downloadStep, new DataflowLinkOptions

cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public UploadPipeline(ISession session, ILogger log, IFileSystem fs)
5353
BoundedCapacity = 1
5454
});
5555

56+
var maxDegreeOfParallelism = fs.CanAccessInParallel ? Environment.ProcessorCount * 2 : 1;
57+
5658
var uploadStep = new ActionBlock<(AssetModel, FilePath)>(async item =>
5759
{
5860
var (asset, path) = item;
@@ -85,9 +87,9 @@ public UploadPipeline(ISession session, ILogger log, IFileSystem fs)
8587
}
8688
}, new ExecutionDataflowBlockOptions
8789
{
88-
MaxDegreeOfParallelism = 8,
90+
MaxDegreeOfParallelism = maxDegreeOfParallelism,
8991
MaxMessagesPerTask = 1,
90-
BoundedCapacity = 16
92+
BoundedCapacity = maxDegreeOfParallelism * 2
9193
});
9294

9395
fileNameStep.LinkTo(uploadStep, new DataflowLinkOptions

cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<TargetFramework>net5.0</TargetFramework>
1515
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
1616
<ToolCommandName>sq</ToolCommandName>
17-
<Version>7.17</Version>
17+
<Version>7.18</Version>
1818
</PropertyGroup>
1919
<ItemGroup>
2020
<None Remove="Commands\Implementation\OpenLibrary\Structure\schemas\author.json" />

0 commit comments

Comments
 (0)