mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
Add rollback capability if update extraction fails
This commit is contained in:
parent
d327095b4b
commit
236b79cc8a
@ -241,7 +241,6 @@ namespace MediaBrowser.Installer
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
||||||
SystemClose("Error Removing Archive - " + e.GetType().FullName + "\n\n" + e.Message);
|
SystemClose("Error Removing Archive - " + e.GetType().FullName + "\n\n" + e.Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -399,17 +398,12 @@ namespace MediaBrowser.Installer
|
|||||||
protected void ExtractPackage(string archive)
|
protected void ExtractPackage(string archive)
|
||||||
{
|
{
|
||||||
// Delete old content of system
|
// Delete old content of system
|
||||||
var systemDir = Path.Combine(RootPath, "system");
|
var systemDir = Path.Combine(RootPath, "System");
|
||||||
|
var backupDir = Path.Combine(RootPath, "System.old");
|
||||||
if (Directory.Exists(systemDir))
|
if (Directory.Exists(systemDir))
|
||||||
{
|
{
|
||||||
try
|
if (Directory.Exists(backupDir)) Directory.Delete(backupDir,true);
|
||||||
{
|
Directory.Move(systemDir, backupDir);
|
||||||
Directory.Delete(systemDir, true);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// we tried...
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// And extract
|
// And extract
|
||||||
@ -437,6 +431,10 @@ namespace MediaBrowser.Installer
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//Rollback
|
||||||
|
if (Directory.Exists(systemDir)) Directory.Delete(systemDir);
|
||||||
|
Directory.Move(backupDir, systemDir);
|
||||||
|
File.Delete(archive); // so we don't try again if its an update
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user