Skip to content

Commit

Permalink
Fix synchronization of singleton schemas.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Jul 28, 2021
1 parent 7234d54 commit a3e6ef8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cli/Squidex.CLI/Squidex.CLI/Commands/App_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ public void Add(AddArguments arguments)
if (arguments.Use)
{
configuration.UseApp(arguments.Name);
}

log.WriteLine("> App added.");
log.WriteLine("> App added and selected.");
}
else
{
log.WriteLine("> App added.");
}
}

[Command(Name = "use", Description = "Use an app.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s
GetFiles(sync.FileSystem)
.Select(x => (x, sync.Read<ContentsModel>(x, log)));

var schemas = await session.Schemas.GetSchemasAsync(session.App);

foreach (var (file, model) in models)
{
if (model?.Contents?.Count > 0)
Expand All @@ -103,7 +105,7 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s
DoNotScript = true,
DoNotValidate = false,
DoNotValidateWorkflow = true,
Jobs = model.Contents.Select(x => x.ToJob()).ToList()
Jobs = model.Contents.Select(x => x.ToJob(schemas)).ToList()
};

var contentIdAssigned = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,27 @@
using System.Linq;
using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Management;

namespace Squidex.CLI.Commands.Implementation.Sync.Contents
{
public static class Extensions
{
public static BulkUpdateJob ToJob(this ContentModel model)
public static BulkUpdateJob ToJob(this ContentModel model, SchemasDto schemas)
{
var id = model.Id;

#pragma warning disable CS0618 // Type or member is obsolete
var singleton = schemas.Items.Single(x => x.Name == model.Schema && x.IsSingleton);
#pragma warning restore CS0618 // Type or member is obsolete
if (singleton != null)
{
id = singleton.Id;
}

return new BulkUpdateJob
{
Id = model.Id,
Id = id,
Data = model.Data,
Schema = model.Schema,
Status = model.Status,
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.9</Version>
<Version>7.10</Version>
</PropertyGroup>
<ItemGroup>
<None Remove="Commands\Implementation\OpenLibrary\Structure\schemas\author.json" />
Expand Down

0 comments on commit a3e6ef8

Please sign in to comment.