Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8bbf3d9
Change to a full set cache policity, so we hit the database less times.
KevinJump Mar 24, 2026
53672a1
update the repo to catch errors (so we don't bork an import/site)
KevinJump Mar 24, 2026
a9ea9e3
Update uSync.Core/Persistance/SyncDataRespositoryBase.cs
KevinJump Mar 24, 2026
af5f1cb
Update uSync.Core/Persistance/SyncDataRespositoryBase.cs
KevinJump Mar 24, 2026
d08f6c8
Update uSync.Core/Migrations/SyncMigrateFullDataSetCachePolicy.cs
KevinJump Mar 24, 2026
de2e814
tidy up cache files.
KevinJump Mar 25, 2026
d30b6a4
clean up semaphore logic, so it can timeout (eventually)
KevinJump Mar 25, 2026
0b0ce25
Update uSync.Core/Persistance/Cache/SyncFullDataSetRepositoryCachePol…
KevinJump Mar 25, 2026
352e450
Update uSync.Core/Migrations/SyncMigratedDataRepository.cs
KevinJump Mar 25, 2026
714eb63
Remove the individual cache policy items (we are using full data set …
KevinJump Mar 25, 2026
430b409
tidy up cache polcy files.
KevinJump Mar 25, 2026
ad75caa
Update uSync.Core/Persistance/Cache/SyncFullDataSetRepositoryCachePol…
KevinJump Mar 25, 2026
8799353
Update uSync.Core/Persistance/Cache/SyncFullDataSetRepositoryCachePol…
KevinJump Mar 25, 2026
90a59d5
Clean the migrated table when someone does a clean export.
KevinJump Mar 25, 2026
d6dabb0
Merge branch 'v17/migrations-full-set-cache-policy' of https://github…
KevinJump Mar 25, 2026
5be4ded
move deleteall into base service (and fix cache notification)
KevinJump Mar 26, 2026
8d44ab4
Removes DB elements from uSync directly, and add new Tracker to pass …
KevinJump Mar 26, 2026
37312ad
Update uSync.Core/Mapping/SyncValueMapperCollection.cs
KevinJump Mar 26, 2026
687f55d
Ensure ISyncMapper new IsMapper method has default implimentation
KevinJump Mar 26, 2026
97d6f45
Merge branch 'v17/migrations-full-set-cache-policy' of https://github…
KevinJump Mar 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions uSync.BackOffice/Services/SyncService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using Microsoft.Extensions.Logging;

using Org.BouncyCastle.Asn1.Ocsp;
using Org.BouncyCastle.Tls;

using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand All @@ -26,6 +23,7 @@
using uSync.BackOffice.SyncHandlers.Models;
using uSync.Core;
using uSync.Core.Extensions;
using uSync.Core.Notifications;
using uSync.Core.Serialization;

namespace uSync.BackOffice;
Expand Down Expand Up @@ -297,6 +295,9 @@ public bool CleanExportFolder(string folder)
{
if (_syncFileService.DirectoryExists(folder))
_syncFileService.CleanFolder(folder);

// tell the migrations table to clean itself too.
_eventAggregator.Publish(new SyncExportCleanNotification());
}
catch (Exception ex)
{
Expand Down
16 changes: 16 additions & 0 deletions uSync.Core/DataTypes/ConfigurationSerializerCollectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ConfigurationSerializerCollection(Func<IEnumerable<IConfigurationSerializ
{
}

[Obsolete("Use GetSerializers instead to get all serializers for an editor alias, getting only the first is not recommended. will be removed in v19")]
public IConfigurationSerializer? GetSerializer(string editorAlias)
=> this.FirstOrDefault(x => x.IsSerializer(editorAlias));

Expand All @@ -39,4 +40,19 @@ public IEnumerable<IConfigurationSerializer> GetSerializers(string editorAlias)
}
return null;
}

/// <summary>
/// tells serializers that care about it that this is a rename
/// </summary>
/// <param name="oldEditorAlias"></param>
/// <param name="newEditorAlias"></param>
public async Task TrackRenamedEditorAsync(string oldEditorAlias, string newEditorAlias) {

foreach(var serializer in GetSerializers(oldEditorAlias))
{
if (serializer is IConfigurationTrackingSerializer trackingSerializer)
await trackingSerializer.TrackRenamedEditorAsync(oldEditorAlias, newEditorAlias);
}

}
}
5 changes: 5 additions & 0 deletions uSync.Core/DataTypes/IConfigurationSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ Task<IDictionary<string, object>> GetConfigurationImportAsync(string name, IDict
bool IsSerializer(string propertyName)
=> Editors.InvariantContains(propertyName);
}

public interface IConfigurationTrackingSerializer : IConfigurationSerializer
{
Task TrackRenamedEditorAsync(string oldEditorAlias, string newEditorAlias);
}
3 changes: 3 additions & 0 deletions uSync.Core/Mapping/ISyncMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public interface ISyncMapper
string Name { get; }
string[] Editors { get; }

bool IsMapper(string editorAlias)
=> Editors.Contains(editorAlias, StringComparer.OrdinalIgnoreCase);

bool IsMapper(PropertyType propertyType);
Comment thread
KevinJump marked this conversation as resolved.

Task<string?> GetExportValueAsync(object value, string editorAlias);
Expand Down
3 changes: 3 additions & 0 deletions uSync.Core/Mapping/SyncValueMapperBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public SyncValueMapperBase(IEntityService entityService)

public abstract string[] Editors { get; }

public virtual bool IsMapper(string editorAlias)
=> Editors.InvariantContains(editorAlias);

public virtual bool IsMapper(PropertyType propertyType)
=> Editors.InvariantContains(propertyType.PropertyEditorAlias);

Expand Down
24 changes: 11 additions & 13 deletions uSync.Core/Mapping/SyncValueMapperCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@

using uSync.Core.Cache;
using uSync.Core.Extensions;
using uSync.Core.Migrations;
using uSync.Core.Mapping.Tracking;
using uSync.Core.Tracking;

namespace uSync.Core.Mapping;

public class SyncValueMapperCollection
: BuilderCollectionBase<ISyncMapper>
{
private readonly ConcurrentDictionary<string, string> _customMappings = new(StringComparer.InvariantCultureIgnoreCase);
private readonly ISyncMigratedDataService _migratedDataService;
private readonly SyncMapperTrackerCollection _mapperTrackers;

private readonly ConcurrentDictionary<string, string> _customMappings = new(StringComparer.InvariantCultureIgnoreCase);

public SyncEntityCache EntityCache { get; private set; }

public SyncValueMapperCollection(
SyncEntityCache entityCache,
Func<IEnumerable<ISyncMapper>> items,
ISyncMigratedDataService migratedDataService)
SyncMapperTrackerCollection mapperTrackers)
: base(items)
{
EntityCache = entityCache;

// todo, load these from config.
_customMappings = [];
_migratedDataService = migratedDataService;
_mapperTrackers = mapperTrackers;
}

/// <summary>
Expand All @@ -37,21 +39,17 @@ public SyncValueMapperCollection(
public IEnumerable<ISyncMapper> GetSyncMappers(string editorAlias)
{
var mappedAlias = GetMapperAlias(editorAlias);
return this.Where(x => x.Editors.InvariantContains(mappedAlias));
return this.Where(m => m.IsMapper(mappedAlias));
}

/// <summary>
/// will get any mappers and any mappers associated with the editor alias that have been migrated (if any)
/// will get any mappers and any mappers that are tracked for the editor alias, this is important because
/// this allows us to support old mappers for a property editor, even if the property editor alias has changed.
/// </summary>
public async Task<IEnumerable<ISyncMapper>> GetImportingSyncMappers(string editorAlias)
{
var mappers = new List<ISyncMapper>();
var importingAlias = await _migratedDataService.GetAsync(editorAlias);
if (importingAlias is not null)
mappers.AddRange(this.Where(x => x.Editors.InvariantContains(importingAlias.Orginal)));

return [.. mappers, ..GetSyncMappers(editorAlias)];
var mappers = await _mapperTrackers.GetMappersAsync(editorAlias);
return [.. mappers, .. GetSyncMappers(editorAlias)];
}

/// <summary>
Expand Down
18 changes: 18 additions & 0 deletions uSync.Core/Mapping/Tracking/ISyncMapperTracker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace uSync.Core.Mapping.Tracking;

/// <summary>
/// tracking for when editors might change.
/// </summary>
/// <remarks>
/// A tracker mapper can return additional ISyncMappers for an editor Alias
/// typically we do this when migrations has tracked that a new editorAlias
/// was once an a different editor alias.
/// </remarks>
public interface ISyncMapperTracker
{
Task<IEnumerable<ISyncMapper>> GetTrackingMappers(string editorAlias);
}
26 changes: 26 additions & 0 deletions uSync.Core/Mapping/Tracking/SyncMapperTrackerCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Umbraco.Cms.Core.Composing;

namespace uSync.Core.Mapping.Tracking;

public class SyncMapperTrackerCollection
: BuilderCollectionBase<ISyncMapperTracker>
{
public SyncMapperTrackerCollection(Func<IEnumerable<ISyncMapperTracker>> items)
: base(items)
{ }

public async Task<IEnumerable<ISyncMapper>> GetMappersAsync(string editorAlias)
{
if (this.Count == 0) return Enumerable.Empty<ISyncMapper>();

var tasks = this.Select(x => x.GetTrackingMappers(editorAlias));
var results = await Task.WhenAll(tasks);
return results.SelectMany(x => x);
}
}

public class SyncMapperTrackerCollectionBuilder
: LazyCollectionBuilderBase<SyncMapperTrackerCollectionBuilder, SyncMapperTrackerCollection, ISyncMapperTracker>
{
protected override SyncMapperTrackerCollectionBuilder This => this;
}
7 changes: 0 additions & 7 deletions uSync.Core/Migrations/ISyncMigratedDataRepository.cs

This file was deleted.

9 changes: 0 additions & 9 deletions uSync.Core/Migrations/ISyncMigratedDataService.cs

This file was deleted.

17 changes: 0 additions & 17 deletions uSync.Core/Migrations/Migrations/CreateMigratedDataTable.cs

This file was deleted.

13 changes: 0 additions & 13 deletions uSync.Core/Migrations/Migrations/SyncMigratedDataMigrationPlan.cs

This file was deleted.

32 changes: 0 additions & 32 deletions uSync.Core/Migrations/SyncMigratedData.cs

This file was deleted.

58 changes: 0 additions & 58 deletions uSync.Core/Migrations/SyncMigratedDataBuilderExtensions.cs

This file was deleted.

26 changes: 0 additions & 26 deletions uSync.Core/Migrations/SyncMigratedDataCachePolicy.cs

This file was deleted.

19 changes: 0 additions & 19 deletions uSync.Core/Migrations/SyncMigratedDataRepository.cs

This file was deleted.

Loading
Loading