Skip to content

Commit

Permalink
Update sn references and raise public version.
Browse files Browse the repository at this point in the history
  • Loading branch information
tusmester committed Jan 3, 2023
1 parent 62faddb commit 05c555c
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 136 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Threading;
using SenseNet.ContentRepository.Search;
using SenseNet.Packaging.Steps;
using SenseNet.Search.Indexing;
using ExecutionContext = SenseNet.Packaging.ExecutionContext;

namespace SenseNet.Preview.Packaging.Steps
Expand Down Expand Up @@ -30,7 +32,8 @@ public override void Execute(ExecutionContext context)

using (new Timer(state => WriteProgress(), null, 1000, 2000))
{
var pc = new PreviewCleaner(Path, Mode, MaxIndex, MaxDegreeOfParallelism, BlockSize);
var indexingEngine = GetService<ISearchManager>()?.SearchEngine?.IndexingEngine;
var pc = new PreviewCleaner(indexingEngine, Path, Mode, MaxIndex, MaxDegreeOfParallelism, BlockSize);
pc.OnFolderDeleted += (s, e) => { Interlocked.Increment(ref _folderCount);};
pc.OnImageDeleted += (s, e) => { Interlocked.Increment(ref _imageCount); };

Expand Down
10 changes: 7 additions & 3 deletions src/Preview/Preview.Controller/Packaging/Steps/PreviewCleaner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using SenseNet.ContentRepository.Storage.Data;
using SenseNet.Diagnostics;
using SenseNet.Search;
using SenseNet.Search.Indexing;
using SenseNet.Search.Querying;
using Retrier = SenseNet.Tools.Retrier;
// ReSharper disable AccessToDisposedClosure
Expand Down Expand Up @@ -78,6 +79,7 @@ ELSE CAST(0 AS BIT)

private int MaxDegreeOfParallelism { get; }
private int BlockSize { get; }
private IIndexingEngine IndexingEngine { get; }

private static readonly Lazy<SnTrace.SnTraceCategory> TraceCategory = new Lazy<SnTrace.SnTraceCategory>(() =>
{
Expand All @@ -93,7 +95,7 @@ ELSE CAST(0 AS BIT)

//========================================================================================= Constructors

public PreviewCleaner(string path = null, CleanupMode cleanupMode = CleanupMode.AllVersions,
public PreviewCleaner(IIndexingEngine indexingEngine, string path = null, CleanupMode cleanupMode = CleanupMode.AllVersions,
int maxIndex = 0, int maxDegreeOfParallelism = 10, int blockSize = 500)
{
Path = path;
Expand All @@ -102,6 +104,8 @@ public PreviewCleaner(string path = null, CleanupMode cleanupMode = CleanupMode.

MaxDegreeOfParallelism = Math.Max(1, maxDegreeOfParallelism);
BlockSize = Math.Max(1, blockSize);

IndexingEngine = indexingEngine;
}

//========================================================================================= Public API
Expand Down Expand Up @@ -256,7 +260,7 @@ private bool DeletePreviewFoldersBlock(string path, bool keepLastVersions, int m

Trace.Write("Removing preview folder block from the index.");

IndexManager.IndexingEngine.WriteIndexAsync(pathBag.SelectMany(p => new[]
IndexingEngine.WriteIndexAsync(pathBag.SelectMany(p => new[]
{
new SnTerm(IndexFieldName.InTree, p),
new SnTerm(IndexFieldName.Path, p)
Expand Down Expand Up @@ -340,7 +344,7 @@ private bool DeleteEmptyPreviewFoldersBlock(string path, int blockSize)

Trace.Write("Removing preview folder block from the index.");

IndexManager.IndexingEngine.WriteIndexAsync(pathBag.SelectMany(p => new[]
IndexingEngine.WriteIndexAsync(pathBag.SelectMany(p => new[]
{
new SnTerm(IndexFieldName.InTree, p),
new SnTerm(IndexFieldName.Path, p)
Expand Down
6 changes: 2 additions & 4 deletions src/Preview/Preview.Controller/Preview.Controller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyName>SenseNet.Preview.Controller</AssemblyName>
<RootNamespace>SenseNet.Preview.Controller</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>7.3.3.1</Version>
<Version>7.3.4</Version>
<Authors>kavics,tusmester,aniko,lajos,bezoo</Authors>
<Company>Sense/Net Inc.</Company>
<Copyright>Copyright © Sense/Net Inc.</Copyright>
Expand All @@ -22,9 +22,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SenseNet.Tools" Version="3.2.7" />
<PackageReference Include="SenseNet.ContentRepository" Version="7.7.27" />
<PackageReference Include="System.Runtime.Caching" Version="4.5" />
<PackageReference Include="SenseNet.ContentRepository" Version="7.7.35" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
</ItemGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/Preview/Preview.Controller/PreviewCommentActions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SenseNet.ApplicationModel;
Expand Down Expand Up @@ -153,7 +154,7 @@ private static void SaveComments(Content content, JToken commentsArray)
file.VersionCreationDate = content.ContentHandler.VersionCreationDate;
file.VersionModifiedBy = content.ContentHandler.VersionModifiedBy;
file.VersionModificationDate = content.ContentHandler.VersionModificationDate;
file.Save(SavingMode.KeepVersion);
file.SaveAsync(SavingMode.KeepVersion, CancellationToken.None).GetAwaiter().GetResult();
}
}
private static void AssertCommentFeature(Content content)
Expand Down
3 changes: 2 additions & 1 deletion src/Preview/Preview.Controller/PreviewCommentData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Newtonsoft.Json;
using SenseNet.Configuration;
using SenseNet.ContentRepository;
using SenseNet.ContentRepository.Storage.Security;

Expand Down Expand Up @@ -70,7 +71,7 @@ public PreviewComment(PreviewCommentData data)
// and check for permissions after.
var caller = AccessProvider.Current.GetOriginalUser();
var user = SystemAccount.Execute(() => string.IsNullOrEmpty(data.CreatedBy) ? null : User.Load(data.CreatedBy));
if (user == null || !SecurityHandler.HasPermission(caller, user.Id, PermissionType.Open))
if (user == null || !Providers.Instance.SecurityHandler.HasPermission(caller, user.Id, PermissionType.Open))
user = User.Somebody;

CreatedBy = new PreviewCommentUser
Expand Down
5 changes: 1 addition & 4 deletions src/Preview/Preview.Controller/PreviewExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using SenseNet.Configuration;
using SenseNet.Preview;
using SenseNet.Tools;

Expand All @@ -8,12 +7,10 @@ namespace SenseNet.Extensions.DependencyInjection
{
public static class PreviewExtensions
{
[Obsolete("In a .Net Core environment please use the AddSenseNetDocumentPreviewProvider method instead.")]
[Obsolete("In a .Net Core environment please use the AddSenseNetDocumentPreviewProvider method instead.", true)]
public static IRepositoryBuilder UseDocumentPreviewProvider(this IRepositoryBuilder repositoryBuilder,
DocumentPreviewProvider previewProvider)
{
Providers.Instance.PreviewProvider = previewProvider;

return repositoryBuilder;
}
}
Expand Down
Loading

0 comments on commit 05c555c

Please sign in to comment.