Skip to content

Commit

Permalink
Improve handling with file systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Oct 21, 2021
1 parent 625ba81 commit 266d795
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface IFileSystem : IDisposable

bool CanWrite => true;

bool CanAccessInParallel => false;

IFile GetFile(FilePath path);

IEnumerable<IFile> GetFiles(FilePath path, string extension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public sealed class ZipFileSystem : IFileSystem

public string FullName => fileInfo.FullName;

public bool CanAccessInParallel => false;

public ZipFileSystem(FileInfo fileInfo)
{
zipArchive = new ZipArchive(fileInfo.Open(FileMode.OpenOrCreate), ZipArchiveMode.Update);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public DownloadPipeline(ISession session, ILogger log, IFileSystem fs)
BoundedCapacity = 1
});

var maxDegreeOfParallelism = fs.CanAccessInParallel ? Environment.ProcessorCount * 2 : 1;

var downloadStep = new ActionBlock<(AssetDto, FilePath)>(async item =>
{
var (asset, path) = item;
Expand Down Expand Up @@ -88,9 +90,9 @@ public DownloadPipeline(ISession session, ILogger log, IFileSystem fs)
}
}, new ExecutionDataflowBlockOptions
{
MaxDegreeOfParallelism = 8,
MaxDegreeOfParallelism = maxDegreeOfParallelism,
MaxMessagesPerTask = 1,
BoundedCapacity = 16
BoundedCapacity = maxDegreeOfParallelism * 2
});

fileNameStep.LinkTo(downloadStep, new DataflowLinkOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public UploadPipeline(ISession session, ILogger log, IFileSystem fs)
BoundedCapacity = 1
});

var maxDegreeOfParallelism = fs.CanAccessInParallel ? Environment.ProcessorCount * 2 : 1;

var uploadStep = new ActionBlock<(AssetModel, FilePath)>(async item =>
{
var (asset, path) = item;
Expand Down Expand Up @@ -85,9 +87,9 @@ public UploadPipeline(ISession session, ILogger log, IFileSystem fs)
}
}, new ExecutionDataflowBlockOptions
{
MaxDegreeOfParallelism = 8,
MaxDegreeOfParallelism = maxDegreeOfParallelism,
MaxMessagesPerTask = 1,
BoundedCapacity = 16
BoundedCapacity = maxDegreeOfParallelism * 2
});

fileNameStep.LinkTo(uploadStep, new DataflowLinkOptions
Expand Down
2 changes: 1 addition & 1 deletion cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<TargetFramework>net5.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<ToolCommandName>sq</ToolCommandName>
<Version>7.17</Version>
<Version>7.18</Version>
</PropertyGroup>
<ItemGroup>
<None Remove="Commands\Implementation\OpenLibrary\Structure\schemas\author.json" />
Expand Down

0 comments on commit 266d795

Please sign in to comment.