Skip to content

Commit

Permalink
Added handler to catch errors when installing a package and rename th…
Browse files Browse the repository at this point in the history
…e package so it doesn't keep failing
  • Loading branch information
cturano committed Sep 15, 2015
1 parent b5b5d48 commit 8e86f58
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
Binary file removed Hhogdev.SitecorePackageDeployer_v1.0.update
Binary file not shown.
Binary file added Hhogdev.SitecorePackageDeployer_v1.1.update
Binary file not shown.
4 changes: 2 additions & 2 deletions SitecorePackageDeployer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
36 changes: 32 additions & 4 deletions SitecorePackageDeployer/Tasks/InstallPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class InstallPackage
//Url to make a request to for restarting the web server
string _restartUrl;
//Determines if the config files should be updated
bool _updateConfigurationFiles;
bool _updateConfigurationFiles;

//Indicates that a package is being installed
static bool _installingPackage;
Expand Down Expand Up @@ -157,12 +157,40 @@ private void InstallPackages()

throw ex;
}
catch (Exception ex)
{
Log.Error("Package install failed", ex, this);

ThreadPool.QueueUserWorkItem(new WaitCallback((ctx) =>
{
try
{
//The update package may be locked because the file object hasn't been disposed. Wait for it.
Thread.Sleep(100);

//I really hate this, but I couldn't find another reliable way to ensure the locked file is closed before I move it.
GC.Collect(2);
GC.WaitForPendingFinalizers();

File.Move(updatePackageFilename, updatePackageFilename + ".error_" + DateTime.Now.ToString("yyyyMMdd.hhmmss"));
}
catch(Exception ex1)
{
Log.Error("Error moving broken package", ex1, this);
}
}));

break;
}
finally
{
//Write logs
installLogger.WriteMessages(Path.Combine(installationHistoryRoot, "Install.log"));
if (installationHistoryRoot != null)
{
//Write logs
installLogger.WriteMessages(Path.Combine(installationHistoryRoot, "Install.log"));

SaveInstallationMessages(installationHistoryRoot, logMessages);
SaveInstallationMessages(installationHistoryRoot, logMessages);
}
}
}
}
Expand Down

0 comments on commit 8e86f58

Please sign in to comment.