bootstrap5 fix to theme creator template, modifications to updater app
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
<main role="main">
|
<main role="main">
|
||||||
<nav class="navbar navbar-expand-md navbar-dark bg-primary fixed-top">
|
<nav class="navbar navbar-expand-md navbar-dark bg-primary fixed-top">
|
||||||
<Logo /><Menu Orientation="Horizontal" />
|
<Logo /><Menu Orientation="Horizontal" />
|
||||||
<div class="controls ml-md-auto">
|
<div class="controls ms-auto">
|
||||||
<div class="controls-group"><UserProfile /> <Login /> <ControlPanel /></div>
|
<div class="controls-group"><UserProfile /> <Login /> <ControlPanel /></div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -50,10 +50,13 @@ namespace Oqtane.Updater
|
|||||||
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
||||||
{
|
{
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(entry.Name))
|
||||||
{
|
{
|
||||||
files.Add(Path.Combine(contentrootfolder, entry.FullName));
|
files.Add(Path.Combine(contentrootfolder, entry.FullName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ensure files are not locked
|
// ensure files are not locked
|
||||||
if (CanAccessFiles(files))
|
if (CanAccessFiles(files))
|
||||||
@ -107,6 +110,8 @@ namespace Oqtane.Updater
|
|||||||
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
||||||
{
|
{
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(entry.Name))
|
||||||
{
|
{
|
||||||
string filename = Path.Combine(contentrootfolder, entry.FullName);
|
string filename = Path.Combine(contentrootfolder, entry.FullName);
|
||||||
if (!Directory.Exists(Path.GetDirectoryName(filename)))
|
if (!Directory.Exists(Path.GetDirectoryName(filename)))
|
||||||
@ -117,6 +122,7 @@ namespace Oqtane.Updater
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// an error occurred extracting a file
|
// an error occurred extracting a file
|
||||||
@ -138,15 +144,12 @@ namespace Oqtane.Updater
|
|||||||
// restore on failure
|
// restore on failure
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
|
File.Delete(file);
|
||||||
string filename = Path.Combine(backupfolder, file.Replace(contentrootfolder + Path.DirectorySeparatorChar, ""));
|
string filename = Path.Combine(backupfolder, file.Replace(contentrootfolder + Path.DirectorySeparatorChar, ""));
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
{
|
{
|
||||||
File.Copy(filename, file);
|
File.Copy(filename, file);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
File.Delete(file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// clean up backup
|
// clean up backup
|
||||||
Directory.Delete(backupfolder, true);
|
Directory.Delete(backupfolder, true);
|
||||||
@ -191,7 +194,12 @@ namespace Oqtane.Updater
|
|||||||
|
|
||||||
private static bool CanAccessFiles(List<string> files)
|
private static bool CanAccessFiles(List<string> files)
|
||||||
{
|
{
|
||||||
// ensure files are not locked by another process - the shutdownTimeLimit defines the duration for app shutdown
|
// ensure files are not locked by another process
|
||||||
|
// the IIS ShutdownTimeLimit defines the duration for app shutdown (default is 90 seconds)
|
||||||
|
// websockets can delay application shutdown (ie. Blazor Server)
|
||||||
|
int retries = 60;
|
||||||
|
int sleep = 2;
|
||||||
|
|
||||||
bool canAccess = true;
|
bool canAccess = true;
|
||||||
FileStream stream = null;
|
FileStream stream = null;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -200,8 +208,8 @@ namespace Oqtane.Updater
|
|||||||
string filepath = files[i];
|
string filepath = files[i];
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
bool locked = true;
|
bool locked = true;
|
||||||
// try up to 30 times
|
|
||||||
while (attempts < 30 && locked)
|
while (attempts < retries && locked)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -217,7 +225,7 @@ namespace Oqtane.Updater
|
|||||||
}
|
}
|
||||||
catch // file is locked by another process
|
catch // file is locked by another process
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000); // wait 1 second
|
Thread.Sleep(sleep * 1000); // wait
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -228,6 +236,7 @@ namespace Oqtane.Updater
|
|||||||
if (locked)
|
if (locked)
|
||||||
{
|
{
|
||||||
canAccess = false;
|
canAccess = false;
|
||||||
|
Console.WriteLine("File Locked: " + filepath);
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user