Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nightly Update #349

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions BLAZAM.Tests/Updates/UpdateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ public async void Update_Returns_ValidDownload()
await latest.Download(null);

Assert.True(latest?.UpdateFile.Exists);
Update_Stages_OK(latest);
Update_Cleanup_OK(latest);
await Update_Stages_OK(latest);
await Update_Cleanup_OK(latest);
}
private async void Update_Stages_OK(ApplicationUpdate latest)
private async Task Update_Stages_OK(ApplicationUpdate latest)
{

await latest.ExtractFiles(null);
Assert.True(latest.UpdateStagingDirectory.Files.Count > 2);

}
private async void Update_Cleanup_OK(ApplicationUpdate latest)
private async Task Update_Cleanup_OK(ApplicationUpdate latest)
{

await latest.CleanStaging(null);
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>0.9.2</AssemblyVersion>
<Version>2024.05.01.2106</Version>
<Version>2024.05.01.2331</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
4 changes: 1 addition & 3 deletions BLAZAM/Pages/Users/ViewUser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@
@bind-Value="@ConfirmPassword"
InputType="InputType.Password" />
}
<DynamicMudInput T=bool Label="@AppLocalization["Require Password Change"]"
@bind-Value="@User.RequirePasswordChange"
Disabled=@(!EditMode || !User.CanUnlock) />


<MudStack Row=true Spacing="0">
<DynamicMudInput T=string Label="@AppLocalization["Email Address"]"
Expand Down
41 changes: 20 additions & 21 deletions BLAZAMUpdate/ApplicationUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,24 @@ private async Task<bool> InitiateFileCopy(JobStep? step)


//Update the updater first
Loggers.UpdateLogger.Debug("Copying updater script");
Loggers.UpdateLogger.Debug("Source: " + UpdateStagingDirectory + "\\updater\\*");
Loggers.UpdateLogger.Debug("Dest: " + _applicationRootDirectory + "updater\\");
Loggers.UpdateLogger?.Debug("Copying updater script");
Loggers.UpdateLogger?.Debug("Source: " + UpdateStagingDirectory + "\\updater\\*");
Loggers.UpdateLogger?.Debug("Dest: " + _applicationRootDirectory + "updater\\");


using var context = await _dbFactory.CreateDbContextAsync();


if (_applicationRootDirectory.Writable)
{
Loggers.UpdateLogger.Warning("The application user has write permission to the application directory!");
Loggers.UpdateLogger?.Warning("The application user has write permission to the application directory!");
try
{
return ApplyFiles();
}
catch (Exception ex)
{
Loggers.UpdateLogger.Error("Error applying update: {@Error}", ex);
Loggers.UpdateLogger?.Error("Error applying update: {@Error}", ex);

}
return false;
Expand All @@ -236,7 +236,7 @@ private async Task<bool> InitiateFileCopy(JobStep? step)
}
catch (Exception ex)
{
Loggers.UpdateLogger.Error("Error applying update: {@Error}", ex);
Loggers.UpdateLogger?.Error("Error applying update: {@Error}", ex);

}
return false;
Expand All @@ -246,7 +246,7 @@ private async Task<bool> InitiateFileCopy(JobStep? step)
}
catch (ApplicationException ex)
{
Loggers.UpdateLogger.Error("Unable to apply files {@Error}", ex);
Loggers.UpdateLogger?.Error("Unable to apply files {@Error}", ex);
return false;
}

Expand All @@ -259,22 +259,22 @@ private async Task<bool> InitiateFileCopy(JobStep? step)

private bool ApplyFiles()
{
Loggers.UpdateLogger.Information("Running update as: " + WindowsIdentity.GetCurrent().Name);
Loggers.UpdateLogger.Information("Updating updater");
Loggers.UpdateLogger?.Information("Running update as: " + WindowsIdentity.GetCurrent().Name);
Loggers.UpdateLogger?.Information("Updating updater");



SystemDirectory updaterDirFromStagedUpdate = new SystemDirectory(UpdateStagingDirectory.Path + "\\updater\\");
SystemDirectory updaterDir = new SystemDirectory(_applicationRootDirectory.Path + "updater\\");
updaterDirFromStagedUpdate.CopyTo(updaterDir);
//File.Copy(UpdateStagingDirectory + "\\updater\\", _applicationRootDirectory + "updater\\", true);
Loggers.UpdateLogger.Information("Updater updated");
Loggers.UpdateLogger?.Information("Updater updated");
//If the updater updated we can run the updater
var updaterRan = InvokeUpdateExecutable();

if (updaterRan)
{
Loggers.UpdateLogger.Information("Update process started");
Loggers.UpdateLogger?.Information("Update process started");

return true;
}
Expand Down Expand Up @@ -313,18 +313,18 @@ private bool InvokeUpdateExecutable()

public async Task<bool> Backup(JobStep? step)
{
Loggers.UpdateLogger.Information("Attempting backup of current version to: " + BackupPath);
Loggers.UpdateLogger?.Information("Attempting backup of current version to: " + BackupPath);
try
{
var result = await Task.Run(() => { return _applicationRootDirectory.CopyTo(BackupDirectory); });

Loggers.UpdateLogger.Debug("Backup result: " + result.ToString());
Loggers.UpdateLogger?.Debug("Backup result: " + result.ToString());

return result;
}
catch (Exception ex)
{
Loggers.UpdateLogger.Error("Backup of current version failed: " + ex.Message);
Loggers.UpdateLogger?.Error("Backup of current version failed: " + ex.Message);
return false;
}
}
Expand All @@ -334,7 +334,7 @@ public async Task<bool> CleanDownload(IJobStep? step)
{
return await Task.Run(() =>
{
Loggers.UpdateLogger.Information("Attempting cleaning of download folder: " + UpdateFile);
Loggers.UpdateLogger?.Information("Attempting cleaning of download folder: " + UpdateFile);

try
{
Expand All @@ -345,7 +345,7 @@ public async Task<bool> CleanDownload(IJobStep? step)
}
catch (Exception ex)
{
Loggers.UpdateLogger.Error("Error while cleaning of download folder: " + UpdateFile + " {@Error}", ex);
Loggers.UpdateLogger?.Error("Error while cleaning of download folder: " + UpdateFile + " {@Error}", ex);

return false;
}
Expand All @@ -363,7 +363,7 @@ public async Task<bool> CleanStaging(IJobStep? step)
}
catch (Exception ex)
{
Loggers.UpdateLogger.Error("Error while cleaning staging directory. {@Error}", ex);
Loggers.UpdateLogger?.Error("Error while cleaning staging directory. {@Error}", ex);
return true;
}
});
Expand All @@ -375,7 +375,7 @@ public async Task<bool> ExtractFiles(JobStep? step)

if (!UpdateFile.Exists) return false;

Loggers.UpdateLogger.Debug("Attempting unzip of " + UpdateFile);
Loggers.UpdateLogger?.Debug("Attempting unzip of " + UpdateFile);

UpdateStagingDirectory.EnsureCreated();

Expand All @@ -385,14 +385,13 @@ public async Task<bool> ExtractFiles(JobStep? step)
{
var zip = new ZipArchive(streamToReadFrom);
zip.ExtractToDirectory(UpdateStagingDirectory.Path, true);

Loggers.UpdateLogger.Debug(UpdateFile + " unzipped successfully to " + UpdateStagingDirectory);
Loggers.UpdateLogger?.Debug(UpdateFile + " unzipped successfully to " + UpdateStagingDirectory);

return true;
}
catch (Exception ex)
{
Loggers.UpdateLogger.Error("Error while extracting update zip {@Error}", ex);
Loggers.UpdateLogger?.Error("Error while extracting update zip {@Error}", ex);

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMUpdate/BLAZAMUpdate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Octokit" Version="10.0.0" />
<PackageReference Include="Octokit" Version="11.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading