Skip to content

Commit c5dfe2d

Browse files
committed
feat: Improve ResolveTemplateIfNeededByApplicationSettingsLookup with recursiveCallCount
1 parent 973789a commit c5dfe2d

File tree

5 files changed

+12
-32
lines changed

5 files changed

+12
-32
lines changed

src/Atc.Installer.Wpf.App/App.xaml.cs

-17
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ public App()
1919
{
2020
EnsureInstallerDirectoriesIsCreated();
2121

22-
FixLegacyInstallerFilesLocation();
23-
2422
RestoreInstallerCustomAppSettingsIfNeeded();
2523

2624
UpdateProjectsInstallerFilesIfNeeded();
@@ -123,21 +121,6 @@ private static void EnsureInstallerDirectoriesIsCreated()
123121
}
124122
}
125123

126-
private static void FixLegacyInstallerFilesLocation()
127-
{
128-
var customAppSettings = new FileInfo(Path.Combine(InstallerTempDirectory.FullName, Constants.CustomAppSettingsFileName));
129-
if (customAppSettings.Exists)
130-
{
131-
File.Move(customAppSettings.FullName, Path.Combine(InstallerProgramDataDirectory.FullName, Constants.CustomAppSettingsFileName));
132-
}
133-
134-
var recentOpenFilesFile = new FileInfo(Path.Combine(InstallerTempDirectory.FullName, Constants.RecentOpenFilesFileName));
135-
if (recentOpenFilesFile.Exists)
136-
{
137-
File.Move(recentOpenFilesFile.FullName, Path.Combine(InstallerProgramDataDirectory.FullName, Constants.RecentOpenFilesFileName));
138-
}
139-
}
140-
141124
private static void RestoreInstallerCustomAppSettingsIfNeeded()
142125
{
143126
var currentFile = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Constants.CustomAppSettingsFileName));

src/Atc.Installer.Wpf.App/Dialogs/CheckForUpdatesBoxDialogViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private async Task DownloadLatestCommandHandler()
123123
if (saveFileDialog.ShowDialog() == true)
124124
{
125125
await File
126-
.WriteAllBytesAsync(saveFileDialog.FileName, downloadBytes)
126+
.WriteAllBytesAsync(saveFileDialog.FileName, downloadBytes, CancellationToken.None)
127127
.ConfigureAwait(true);
128128
}
129129
}

src/Atc.Installer.Wpf.App/MainWindowViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private void StartMonitoringServices()
163163
while (!cancellationTokenSource.Token.IsCancellationRequested)
164164
{
165165
await Task
166-
.Delay(3_000, CancellationToken.None)
166+
.Delay(TimeSpan.FromSeconds(3), CancellationToken.None)
167167
.ConfigureAwait(true);
168168

169169
foreach (var vm in ComponentProviders)

src/Atc.Installer.Wpf.ComponentProvider/ComponentProviderViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public ComponentProviderViewModel(
6161
HostingFramework = applicationOption.HostingFramework;
6262
IsService = applicationOption.ComponentType is ComponentType.PostgreSqlServer or ComponentType.InternetInformationService or ComponentType.WindowsService;
6363
InstallationFile = applicationOption.InstallationFile;
64-
InstallationFolderPath = applicationOption.InstallationPath;
64+
InstallationFolderPath = ResolveTemplateIfNeededByApplicationSettingsLookup(applicationOption.InstallationPath);
6565
ResolveInstalledMainFile(applicationOption);
6666

6767
foreach (var dependentServiceName in applicationOption.DependentServices)

src/Atc.Installer.Wpf.ComponentProvider/ComponentProviderViewModel_LogicBase.cs

+9-12
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ protected void EnsureFolderPermissions()
388388
}
389389

390390
protected string ResolveTemplateIfNeededByApplicationSettingsLookup(
391-
string value)
391+
string value,
392+
int recursiveCallCount = 0)
392393
{
393394
if (value.ContainsTemplateKeyBrackets())
394395
{
@@ -415,6 +416,12 @@ protected string ResolveTemplateIfNeededByApplicationSettingsLookup(
415416
}
416417
}
417418

419+
if (recursiveCallCount <= 3 &&
420+
value.ContainsTemplateKeyBrackets())
421+
{
422+
value = ResolveTemplateIfNeededByApplicationSettingsLookup(value, recursiveCallCount + 1);
423+
}
424+
418425
return value;
419426
}
420427

@@ -495,17 +502,7 @@ private void ResolveDirectoriesForFolderPermissions()
495502
folder = ResolvedVirtuelRootFolder(folder);
496503
}
497504

498-
if (folder.ContainsTemplateKeyBrackets())
499-
{
500-
var keys = folder.GetTemplateKeys();
501-
foreach (var key in keys)
502-
{
503-
if (TryGetStringFromApplicationSettings(key, out var resultValue))
504-
{
505-
folder = folder.ReplaceTemplateWithKey(key, resultValue);
506-
}
507-
}
508-
}
505+
folder = ResolveTemplateIfNeededByApplicationSettingsLookup(folder);
509506

510507
vm.Directory = new DirectoryInfo(folder);
511508
}

0 commit comments

Comments
 (0)