-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCreateIndexDirectoryAction.cs
More file actions
47 lines (40 loc) · 1.4 KB
/
CreateIndexDirectoryAction.cs
File metadata and controls
47 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using JetBrains.Annotations;
using SIM.Extensions;
using Sitecore.Diagnostics.Base;
namespace SIM.Pipelines.InstallSearchIndexes
{
public class CreateIndexDirectoryAction : InstallSearchIndexesProcessor
{
protected override void Process([NotNull] InstallSearchIndexesArgs args)
{
Assert.ArgumentNotNull(args, nameof(args));
foreach (var index in args._AvailableSearchIndexesDictionary)
{
string newCorePath = args.SolrFolder.EnsureEnd(@"\") + index.Value;
CreateIndexDirectory(args.SolrVersion, args.SolrFolder, newCorePath);
}
}
private void CreateIndexDirectory(string solrVersion, string solrFolder, string newCorePath)
{
string sourcePath = GetSourceConfPath(solrVersion, solrFolder);
FileSystem.FileSystem.Local.Directory.Copy(sourcePath, newCorePath, recursive: true);
}
private string GetSourceConfPath(string solrVersion, string solrFolder)
{
string confPath = string.Empty;
if (!string.IsNullOrEmpty(solrVersion) && char.IsDigit(solrVersion[0]))
{
int firstDigit = int.Parse(solrVersion[0].ToString());
if (firstDigit >= 7)
{
confPath = solrFolder.EnsureEnd(@"\") + @"\configsets\_default";
}
else
{
confPath = solrFolder.EnsureEnd(@"\") + @"\configsets\data_driven_schema_configs";
}
}
return confPath;
}
}
}