From 5c7ed75cde9f57cf24215f8e532c3f50b4e3fb58 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 16 Nov 2021 22:24:28 +0100 Subject: [PATCH] Fix bug in download and upload pipeline --- cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs | 1 - cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs | 1 - .../Implementation/OpenLibrary/AuthorContent.cs | 1 - .../Implementation/OpenLibrary/AuthorImporter.cs | 1 - .../Implementation/Sync/App/AppSynchronizer.cs | 1 - .../Implementation/Sync/Assets/AssetsSynchronizer.cs | 6 +++++- .../Implementation/Sync/Assets/DownloadPipeline.cs | 4 +--- .../Implementation/Sync/Assets/UploadPipeline.cs | 12 ++---------- cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj | 2 +- 9 files changed, 9 insertions(+), 20 deletions(-) diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs index 8e9e6f37..6a212509 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs @@ -6,7 +6,6 @@ // ========================================================================== using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs index c581a312..d6d56754 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs @@ -7,7 +7,6 @@ using System; using System.IO; -using System.Linq; using System.Threading; using System.Threading.Tasks; using CommandDotNet; diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorContent.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorContent.cs index d17a8717..07d412da 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorContent.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorContent.cs @@ -5,7 +5,6 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using System; using Newtonsoft.Json; using Squidex.ClientLibrary; diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorImporter.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorImporter.cs index 9245259d..7d363050 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorImporter.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/OpenLibrary/AuthorImporter.cs @@ -13,7 +13,6 @@ using System.Threading.Tasks.Dataflow; using CsvHelper; using CsvHelper.Configuration; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Squidex.ClientLibrary; diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/App/AppSynchronizer.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/App/AppSynchronizer.cs index 46434bf6..2d3b15f2 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/App/AppSynchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/App/AppSynchronizer.cs @@ -6,7 +6,6 @@ // ========================================================================== using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Squidex.CLI.Commands.Implementation.FileSystem; using Squidex.ClientLibrary.Management; diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/AssetsSynchronizer.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/AssetsSynchronizer.cs index fba1139e..94c5b70d 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/AssetsSynchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/AssetsSynchronizer.cs @@ -99,6 +99,8 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s var tree = new FolderTree(session); + var batchIndex = 0; + foreach (var (_, model) in models) { if (model?.Assets?.Count > 0) @@ -140,7 +142,7 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s var result1 = results.FirstOrDefault(x => x.JobIndex == (assetIndex * 2)); var result2 = results.FirstOrDefault(x => x.JobIndex == (assetIndex * 2) + 1); - log.StepStart($"Upserting #{assetIndex}"); + log.StepStart($"Upserting #{batchIndex}/{assetIndex}"); if (result1?.Error != null) { @@ -162,6 +164,8 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s assetIndex++; } } + + batchIndex++; } } diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs index 841c8313..6d358518 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/DownloadPipeline.cs @@ -6,8 +6,6 @@ // ========================================================================== using System; -using System.IO; -using System.Security.Cryptography; using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; using Squidex.CLI.Commands.Implementation.FileSystem; @@ -111,7 +109,7 @@ public Task DownloadAsync(AssetDto asset) public Task CompleteAsync() { - pipelineEnd.Complete(); + pipelineStart.Complete(); return pipelineEnd.Completion; } diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs index fbed9931..a561d1ed 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Sync/Assets/UploadPipeline.cs @@ -6,7 +6,6 @@ // ========================================================================== using System; -using System.Collections.Generic; using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; using Squidex.CLI.Commands.Implementation.FileSystem; @@ -71,14 +70,7 @@ public UploadPipeline(ISession session, ILogger log, IFileSystem fs) var result = await session.Assets.PostUpsertAssetAsync(session.App, asset.Id, null, true, file); - if (string.Equals(asset.FileHash, result.FileHash, StringComparison.Ordinal)) - { - log.ProcessSkipped(process, "Same hash."); - } - else - { - log.ProcessCompleted(process); - } + log.ProcessCompleted(process); } } catch (Exception ex) @@ -108,7 +100,7 @@ public Task UploadAsync(AssetModel asset) public Task CompleteAsync() { - pipelineEnd.Complete(); + pipelineStart.Complete(); return pipelineEnd.Completion; } diff --git a/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj b/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj index afe06247..9ca21d13 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj +++ b/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj @@ -14,7 +14,7 @@ net5.0 true sq - 7.23 + 7.24