Installer is now 'fully' working

This commit is contained in:
Shannon
2016-06-14 14:12:10 +02:00
parent a8c71e52ec
commit 3fcb2a7840
14 changed files with 340 additions and 160 deletions

View File

@@ -5,7 +5,7 @@
**/
function ourPackageRepositoryResource($q, $http, umbDataFormatter, umbRequestHelper) {
var baseurl = "http://localhost:24292/webapi/packages/v1";
var baseurl = "https://our.umbraco.org/webapi/packages/v1";
return {

View File

@@ -31,7 +31,7 @@ function FormsController($scope, $route, $cookieStore, packageResource) {
return packageResource.installFiles(pack);
}, $scope.error)
.then(function(pack){
$scope.state = "Restarting, please hold...";
$scope.state = "Restarting, please wait...";
return packageResource.installData(pack);
}, $scope.error)
.then(function(pack){

View File

@@ -1,34 +1,47 @@
(function () {
"use strict";
function PackagesOverviewController($scope, $route, $location, navigationService, $timeout) {
function PackagesOverviewController($scope, $route, $location, navigationService, $timeout, $cookieStore) {
var vm = this;
//Hack!
// if there is a cookie value for packageInstallUri then we need to redirect there,
// the issue is that we still have webforms and we cannot go to a hash location and then window.reload
// because it will double load it.
// we will refresh and then navigate there.
var installPackageUri = window.localStorage.getItem("packageInstallUri");
if (installPackageUri) {
window.localStorage.removeItem("packageInstallUri");
$location.path(installPackageUri).search("");
}
else {
var vm = this;
vm.page = {};
vm.page.name = "Packages";
vm.page.navigation = [
{
"name": "Packages",
"icon": "icon-cloud",
"view": "views/packager/views/repo.html",
"active": true
},
{
"name": "Installed",
"icon": "icon-box",
"view": "views/packager/views/installed.html"
},
{
"name": "Install local",
"icon": "icon-add",
"view": "views/packager/views/install-local.html"
}
];
vm.page = {};
vm.page.name = "Packages";
vm.page.navigation = [
{
"name": "Packages",
"icon": "icon-cloud",
"view": "views/packager/views/repo.html",
"active": true
},
{
"name": "Installed",
"icon": "icon-box",
"view": "views/packager/views/installed.html"
},
{
"name": "Install local",
"icon": "icon-add",
"view": "views/packager/views/install-local.html"
}
];
$timeout(function () {
navigationService.syncTree({ tree: "packager", path: "-1" });
});
$timeout(function () {
navigationService.syncTree({ tree: "packager", path: "-1" });
});
}
}

View File

@@ -1,7 +1,7 @@
(function () {
"use strict";
function PackagesInstallLocalController($scope, $route, $location, Upload, umbRequestHelper, packageResource, $cookieStore, versionHelper) {
function PackagesInstallLocalController($scope, $route, $location, Upload, umbRequestHelper, packageResource, $cookieStore, $timeout) {
var vm = this;
vm.state = "upload";
@@ -57,30 +57,7 @@
// set done status on file
vm.zipFile.uploadStatus = "done";
loadPackage();
vm.localPackage = data;
vm.localPackage.allowed = true;
//now we need to determine if this package is compatible to be installed
if (vm.localPackage.umbracoVersion) {
//0 if the versions are equal
//a negative integer iff v1 < v2
//a positive integer iff v1 > v2
//ensure we aren't comparing the pre-release value
var versionNumber = Umbraco.Sys.ServerVariables.application.version.split("-")[0];
var compare = versionHelper.versionCompare(
versionNumber,
vm.localPackage.umbracoVersion);
if (compare < 0) {
//this is not compatible!
vm.localPackage.allowed = false;
vm.installState.status =
"This package cannot be installed, it requires a minimum Umbraco version of " +
vm.localPackage.umbracoVersion;
}
}
}
}).error(function (evt, status, headers, config) {
@@ -123,6 +100,16 @@
//TODO: If any of these fail, will they keep calling the next one?
packageResource
.installFiles(vm.localPackage)
.then(function(pack) {
vm.installState.status = "Importing...";
return packageResource.import(pack);
},
installError)
.then(function(pack) {
vm.installState.status = "Installing...";
return packageResource.installFiles(pack);
},
installError)
.then(function(pack) {
vm.installState.status = "Restarting, please wait...";
return packageResource.installData(pack);
@@ -133,17 +120,20 @@
return packageResource.cleanUp(pack);
},
installError)
.then(function (result) {
.then(function(result) {
if (result.postInstallationPath) {
window.location.href = url;
}
else {
var url = window.location.href + "?installed=" + vm.localPackage.packageGuid;
window.location.reload(true);
}
if (result.postInstallationPath) {
//Put the redirect Uri in a cookie so we can use after reloading
window.localStorage.setItem("packageInstallUri", result.postInstallationPath);
}
//reload on next digest (after cookie)
$timeout(function() {
window.location.reload(true);
});
}, installError);
},
installError);
}
function installError() {

View File

@@ -73,7 +73,7 @@
<div class="umb-info-local-item">
<strong>Version</strong>
{{ vm.package.version }}
{{ vm.localPackage.version }}
</div>
<div class="umb-info-local-item">
@@ -84,10 +84,10 @@
<div class="umb-info-local-item">
<strong>Read me</strong>
<br>
<small> {{ vm.localPackage.readme }} </small>
<small ng-bind-html-unsafe="vm.localPackage.readMe"></small>
</div>
<div class="umb-info-local-item mt-3" ng-if="vm.installState.status == '' && vm.localPackage.allowed">
<div class="umb-info-local-item mt-3" ng-if="vm.installState.status == '' && vm.localPackage.isCompatible">
<button type="button"
ng-class="{'-inactive' : localPackageForm.$invalid}"
ng-disabled="localPackageForm.$invalid"
@@ -96,11 +96,14 @@
Install package
</button>
<label for="license-accept" class="umb-package-installer-label">
<input type="checkbox" id="license-accept" ng-model="vm.localPackage.packageLicenseAccept" required>
<strong class="label-text">I accept <a href="{{ vm.package.licenseUrl }}">terms of use</a></strong>
<input type="checkbox" id="license-accept" ng-model="vm.localPackage.packageLicenseAccept" required no-dirty-check>
<strong class="label-text">I accept <a href="{{ vm.localPackage.licenseUrl }}">terms of use</a></strong>
</label>
</div>
<div class="umb-info-local-item">
<div class="umb-info-local-item text-error" ng-if="!vm.localPackage.isCompatible">
This package cannot be installed, it requires a minimum Umbraco version of {{vm.localPackage.umbracoVersion}}
</div>
<div class="umb-info-local-item text-info">
<p>{{vm.installState.status}}</p>
</div>

View File

@@ -18,6 +18,8 @@
.then(function (packs) {
vm.installedPackages = packs;
});
vm.installState.status = "";
vm.state = "list";
}
function confirmUninstall(pck) {
@@ -28,9 +30,16 @@
function uninstallPackage(installedPackage) {
vm.installState.status = "Uninstalling package...";
packageResource.uninstall(installedPackage.id)
.then(function() {
var url = window.location.href + "?uninstalled=" + vm.package.packageGuid;
window.location.reload(true);
.then(function () {
if (installedPackage.files.length > 0) {
vm.installState.status = "All done, your browser will now refresh";
var url = window.location.href + "?uninstalled=" + vm.package.packageGuid;
window.location.reload(true);
}
else {
init();
}
});
}

View File

@@ -83,11 +83,11 @@
Uninstall package
</button>
<label for="confirm-uninstall" class="umb-package-installer-label">
<input type="checkbox" id="confirm-uninstall" ng-model="vm.package.confirmUninstall" required>
<input type="checkbox" id="confirm-uninstall" ng-model="vm.package.confirmUninstall" required no-dirty-check>
<strong class="label-text">Confirm package uninstall</strong>
</label>
</div>
<div class="umb-info-local-item">
<div class="umb-info-local-item text-info">
<p>{{vm.installState.status}}</p>
</div>

View File

@@ -1,26 +1,30 @@
(function () {
"use strict";
function PackagesRepoController($scope, $route, $location, $timeout, ourPackageRepositoryResource, $q) {
function PackagesRepoController($scope, $route, $location, $timeout, ourPackageRepositoryResource, $q, packageResource, $cookieStore) {
var vm = this;
vm.packageViewState = "packageList";
vm.categories = [];
vm.loading = false;
vm.loading = true;
vm.pagination = {
pageNumber: 1,
totalPages: 10,
pageSize: 2
pageSize: 8
};
vm.searchQuery = "";
vm.installState = {
status: ""
};
vm.selectCategory = selectCategory;
vm.showPackageDetails = showPackageDetails;
vm.setPackageViewState = setPackageViewState;
vm.nextPage = nextPage;
vm.prevPage = prevPage;
vm.goToPage = goToPage;
vm.installPackage = installPackage;
vm.downloadPackage = downloadPackage;
//used to cancel any request in progress if another one needs to take it's place
var canceler = null;
@@ -91,10 +95,7 @@
canceler = null;
});
}
}
else {
vm.loading = false;
}
}
});
}, 200));
@@ -175,6 +176,61 @@
});
}
function downloadPackage(selectedPackage) {
vm.loading = true;
packageResource
.fetch(selectedPackage.id)
.then(function(pack) {
vm.packageViewState = "packageInstall";
vm.loading = false;
vm.localPackage = pack;
vm.localPackage.allowed = true;
},
error);
}
function error(e, args) {
}
function installPackage(selectedPackage) {
vm.installState.status = "importing...";
packageResource
.import(selectedPackage)
.then(function(pack) {
vm.installState.status = "Installing...";
return packageResource.installFiles(pack);
},
error)
.then(function(pack) {
vm.installState.status = "Restarting, please wait...";
return packageResource.installData(pack);
},
error)
.then(function(pack) {
vm.installState.status = "All done, your browser will now refresh";
return packageResource.cleanUp(pack);
},
error)
.then(function(result) {
if (result.postInstallationPath) {
//Put the redirect Uri in a cookie so we can use after reloading
window.localStorage.setItem("packageInstallUri", result.postInstallationPath);
}
//reload on next digest (after cookie)
$timeout(function () {
window.location.reload(true);
});
},
error);
}
init();
}

View File

@@ -7,7 +7,7 @@
<div class="umb-packages-section">
<div class="umb-packages-search">
<input class="-full-width-input" type="text" name="query" placeholder="Search for packages" umb-auto-focus ng-model="vm.searchQuery">
<input class="-full-width-input" type="text" name="query" placeholder="Search for packages" umb-auto-focus ng-model="vm.searchQuery" no-dirty-check>
</div>
</div>
@@ -131,13 +131,13 @@
<div class="umb-package-details__sidebar">
<div class="umb-package-details__section">
<button class="umb-era-button -blue -full-width">Install package</button>
<button class="umb-era-button -blue -full-width" ng-click="vm.downloadPackage(vm.package)">Install package</button>
</div>
<div class="umb-package-details__section">
<div class="umb-package-details__owner-profile">
<div class="umb-package-details__owner-profile-avatar">
<img class="umb-avatar" ng-src="{{vm.package.ownerInfo.ownerAvatar}}" />
<img class="umb-avatar" ng-src="{{ 'https://our.umbraco.org' + vm.package.ownerInfo.ownerAvatar }}" />
</div>
<div>
<div class="umb-package-details__owner-profile-name">{{ vm.package.ownerInfo.owner }}</div>
@@ -227,8 +227,67 @@
</div>
</div>
</div>
<!-- Package details -->
<div class="umb-info-local" ng-if="vm.packageViewState === 'packageInstall' && vm.loading === false">
<div class="umb-info-local-items">
<form novalidate name="localPackageForm">
<div class="umb-package-icon">
<i ng-if="!vm.localPackage.icon" class="icon-box"></i>
<img ng-if="vm.localPackage.icon" ng-src="{{vm.localPackage.icon}}" alt="" />
</div>
<div class="umb-package-info">
<h4 class="umb-info-local-item"><strong>{{ vm.localPackage.name }}</strong></h4>
<div class="umb-info-local-item">
<strong>Author</strong>
<a href="{{ vm.localPackage.authorLink }}" target="_blank">{{ vm.localPackage.author }}</a>
</div>
<div class="umb-info-local-item">
<strong>Version</strong>
{{ vm.localPackage.version }}
</div>
<div class="umb-info-local-item">
<strong>License</strong>
<a href="{{ vm.localPackage.licenseUrl }}">{{ vm.localPackage.license }}</a>
</div>
<div class="umb-info-local-item">
<strong>Read me</strong>
<br>
<small ng-bind-html-unsafe="vm.localPackage.readMe"></small>
</div>
<div class="umb-info-local-item mt-3" ng-if="vm.installState.status == '' && vm.localPackage.isCompatible">
<button type="button"
ng-class="{'-inactive' : localPackageForm.$invalid}"
ng-disabled="localPackageForm.$invalid"
class="umb-era-button -blue inline-flex"
ng-click="vm.installPackage(vm.localPackage)">
Install package
</button>
<label for="license-accept" class="umb-package-installer-label">
<input type="checkbox" id="license-accept" ng-model="vm.localPackage.packageLicenseAccept" required no-dirty-check>
<strong class="label-text">I accept <a href="{{ vm.localPackage.licenseUrl }}">terms of use</a></strong>
</label>
</div>
<div class="umb-info-local-item text-error" ng-if="!vm.localPackage.isCompatible">
This package cannot be installed, it requires a minimum Umbraco version of {{vm.localPackage.umbracoVersion}}
</div>
<div class="umb-info-local-item text-info">
<p>{{vm.installState.status}}</p>
</div>
</div>
</form>
</div>
</div>
</div>

View File

@@ -218,10 +218,52 @@ namespace Umbraco.Web.Editors
Version = pack.Version,
Url = pack.Url,
License = pack.License,
LicenseUrl = pack.LicenseUrl
LicenseUrl = pack.LicenseUrl,
Files = pack.Files
}).ToList();
}
private void PopulateFromPackageData(LocalPackageInstallModel model)
{
var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);
//this will load in all the metadata too
var tempDir = ins.Import(model.ZipFilePath, false);
model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, tempDir);
model.Name = ins.Name;
model.Author = ins.Author;
model.AuthorUrl = ins.AuthorUrl;
model.License = ins.License;
model.LicenseUrl = ins.LicenseUrl;
model.ReadMe = ins.ReadMe;
model.ConflictingMacroAliases = ins.ConflictingMacroAliases;
model.ConflictingStyleSheetNames = ins.ConflictingStyleSheetNames;
model.ConflictingTemplateAliases = ins.ConflictingTemplateAliases;
model.ContainsBinaryFileErrors = ins.ContainsBinaryFileErrors;
model.ContainsLegacyPropertyEditors = ins.ContainsLegacyPropertyEditors;
model.ContainsMacroConflict = ins.ContainsMacroConflict;
model.ContainsStyleSheetConflicts = ins.ContainsStyleSheeConflicts;
model.ContainsTemplateConflicts = ins.ContainsTemplateConflicts;
model.ContainsUnsecureFiles = ins.ContainsUnsecureFiles;
model.Url = ins.Url;
model.Version = ins.Version;
model.UmbracoVersion = ins.RequirementsType == RequirementsType.Strict
? string.Format("{0}.{1}.{2}", ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch)
: string.Empty;
//now we need to check for version comparison
model.IsCompatible = true;
if (ins.RequirementsType == RequirementsType.Strict)
{
var packageMinVersion = new System.Version(ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch);
if (UmbracoVersion.Current < packageMinVersion)
{
model.IsCompatible = false;
}
}
}
[HttpPost]
[FileUploadCleanupFilter(false)]
public async Task<LocalPackageInstallModel> UploadLocalPackage()
@@ -269,65 +311,14 @@ namespace Umbraco.Web.Editors
//the file name must be a GUID - this is what the packager expects (strange yes)
//because essentially this is creating a temporary package Id that will be used
//for unpacking/installing/etc...
var packageTempFileName = model.PackageGuid + ".umb";
var packageTempFileLocation = Path.Combine(packageTempDir, packageTempFileName);
model.ZipFilePath = model.PackageGuid + ".umb";
var packageTempFileLocation = Path.Combine(packageTempDir, model.ZipFilePath);
File.Copy(file.LocalFileName, packageTempFileLocation, true);
try
{
var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);
//this will load in all the metadata too
var tempDir = ins.Import(packageTempFileName);
//Populate the model from the metadata in the package file (zip file)
PopulateFromPackageData(model);
//now we need to check for version comparison
if (ins.RequirementsType == RequirementsType.Strict)
{
var packageMinVersion = new System.Version(ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch);
if (UmbracoVersion.Current < packageMinVersion)
{
throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("This package cannot be installed, it requires a minimum Umbraco version of " + packageMinVersion));
}
}
model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, tempDir);
model.Id = ins.CreateManifest(
IOHelper.MapPath(model.TemporaryDirectoryPath),
model.PackageGuid.ToString(),
//TODO: Does this matter? we're installing a local package
string.Empty);
model.Name = ins.Name;
model.Author = ins.Author;
model.AuthorUrl = ins.AuthorUrl;
model.License = ins.License;
model.LicenseUrl = ins.LicenseUrl;
model.ReadMe = ins.ReadMe;
model.ConflictingMacroAliases = ins.ConflictingMacroAliases;
model.ConflictingStyleSheetNames = ins.ConflictingStyleSheetNames;
model.ConflictingTemplateAliases = ins.ConflictingTemplateAliases;
model.ContainsBinaryFileErrors = ins.ContainsBinaryFileErrors;
model.ContainsLegacyPropertyEditors = ins.ContainsLegacyPropertyEditors;
model.ContainsMacroConflict = ins.ContainsMacroConflict;
model.ContainsStyleSheetConflicts = ins.ContainsStyleSheeConflicts;
model.ContainsTemplateConflicts = ins.ContainsTemplateConflicts;
model.ContainsUnsecureFiles = ins.ContainsUnsecureFiles;
model.Url = ins.Url;
model.Version = ins.Version;
model.UmbracoVersion = ins.RequirementsType == RequirementsType.Strict
? string.Format("{0}.{1}.{2}", ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch)
: string.Empty;
//TODO: We need to add the 'strict' requirement to the installer
}
finally
{
//Cleanup file
if (File.Exists(packageTempFileLocation))
{
File.Delete(packageTempFileLocation);
}
}
//TODO: We need to add the 'strict' requirement to the installer
}
else
{
@@ -349,7 +340,7 @@ namespace Umbraco.Web.Editors
/// <param name="packageGuid"></param>
/// <returns></returns>
[HttpGet]
public PackageInstallModel Fetch(string packageGuid)
public LocalPackageInstallModel Fetch(string packageGuid)
{
//Default path
string path = Path.Combine("packages", packageGuid + ".umb");
@@ -361,14 +352,18 @@ namespace Umbraco.Web.Editors
path = our.fetch(packageGuid, Security.CurrentUser.Id);
}
}
var p = new PackageInstallModel();
p.PackageGuid = Guid.Parse(packageGuid);
p.RepositoryGuid = Guid.Parse("65194810-1f85-11dd-bd0b-0800200c9a66");
p.ZipFilePath = path;
//p.ZipFilePath = Path.Combine("temp", "package.umb");
return p;
var model = new LocalPackageInstallModel
{
PackageGuid = Guid.Parse(packageGuid),
RepositoryGuid = Guid.Parse("65194810-1f85-11dd-bd0b-0800200c9a66"),
ZipFilePath = path
};
//Populate the model from the metadata in the package file (zip file)
PopulateFromPackageData(model);
return model;
}
/// <summary>
@@ -380,7 +375,19 @@ namespace Umbraco.Web.Editors
public PackageInstallModel Import(PackageInstallModel model)
{
var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);
model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, ins.Import(model.ZipFilePath));
var tempPath = ins.Import(model.ZipFilePath);
//now we need to check for version comparison
if (ins.RequirementsType == RequirementsType.Strict)
{
var packageMinVersion = new System.Version(ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch);
if (UmbracoVersion.Current < packageMinVersion)
{
throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("This package cannot be installed, it requires a minimum Umbraco version of " + packageMinVersion));
}
}
model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, tempPath);
model.Id = ins.CreateManifest( IOHelper.MapPath(model.TemporaryDirectoryPath), model.PackageGuid.ToString(), model.RepositoryGuid.ToString());
return model;
@@ -423,6 +430,7 @@ namespace Umbraco.Web.Editors
public PackageInstallResult CleanUp(PackageInstallModel model)
{
var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);
var tempDir = IOHelper.MapPath(model.TemporaryDirectoryPath);
ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
ins.InstallCleanUp(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));
@@ -435,6 +443,20 @@ namespace Umbraco.Web.Editors
global::umbraco.BusinessLogic.Actions.Action.ReRegisterActionsAndHandlers();
var redirectUrl = "";
if (ins.Control.IsNullOrWhiteSpace())
{
redirectUrl = string.Format("/developer/framed/{0}",
Uri.EscapeDataString(
string.Format("/umbraco/developer/Packages/installer.aspx?installing=custominstaller&dir={0}&pId={1}&customUrl={2}", tempDir, model.Id, ins.Url)));
}
else
{
redirectUrl = string.Format("/developer/framed/{0}",
Uri.EscapeDataString(
string.Format("/umbraco/developer/Packages/installer.aspx?installing=custominstaller&dir={0}&pId={1}&customControl={2}&customUrl={3}", tempDir, model.Id, ins.Control, ins.Url)));
}
return new PackageInstallResult
{
Id = model.Id,
@@ -442,8 +464,9 @@ namespace Umbraco.Web.Editors
PackageGuid = model.PackageGuid,
RepositoryGuid = model.RepositoryGuid,
TemporaryDirectoryPath = model.TemporaryDirectoryPath,
PostInstallationPath = redirectUrl
};
}

View File

@@ -21,6 +21,12 @@ namespace Umbraco.Web.Models
[DataMember(Name = "notifications")]
public List<Notification> Notifications { get; private set; }
/// <summary>
/// A flag to determine if this package is compatible to be installed
/// </summary>
[DataMember(Name = "isCompatible")]
public bool IsCompatible { get; set; }
/// <summary>
/// The minimum umbraco version that this package is pinned to
/// </summary>

View File

@@ -9,6 +9,6 @@ namespace Umbraco.Web.Models
public class PackageInstallResult : PackageInstallModel
{
[DataMember(Name = "postInstallationPath")]
public Guid PostInstallationPath { get; set; }
public string PostInstallationPath { get; set; }
}
}

View File

@@ -331,6 +331,9 @@ namespace umbraco
using (var safeXml = GetSafeXmlWriter(false))
{
//TODO: This can be null: safeXml.Xml!!!!
var node = safeXml.Xml.GetElementById(c.Id.ToString(CultureInfo.InvariantCulture));
if (node == null) return;
var attr = node.GetAttributeNode("sortOrder");

View File

@@ -178,24 +178,25 @@ namespace umbraco.cms.businesslogic.packager
/// <summary>
/// Imports the specified package
/// </summary>
/// <param name="InputFile">Filename of the umbracopackage</param>
/// <param name="inputFile">Filename of the umbracopackage</param>
/// <param name="deleteFile">true if the input file should be deleted after import</param>
/// <returns></returns>
public string Import(string InputFile)
public string Import(string inputFile, bool deleteFile)
{
using (DisposableTimer.DebugDuration<Installer>(
() => "Importing package file " + InputFile,
() => "Package file " + InputFile + "imported"))
() => "Importing package file " + inputFile,
() => "Package file " + inputFile + "imported"))
{
var tempDir = "";
if (File.Exists(IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + InputFile)))
if (File.Exists(IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + inputFile)))
{
var fi = new FileInfo(IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + InputFile));
var fi = new FileInfo(IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + inputFile));
// Check if the file is a valid package
if (fi.Extension.ToLower() == ".umb")
{
try
{
tempDir = UnPack(fi.FullName);
tempDir = UnPack(fi.FullName, deleteFile);
LoadConfig(tempDir);
}
catch (Exception unpackE)
@@ -207,9 +208,20 @@ namespace umbraco.cms.businesslogic.packager
throw new Exception("Error - file isn't a package (doesn't have a .umb extension). Check if the file automatically got named '.zip' upon download.");
}
else
throw new Exception("Error - file not found. Could find file named '" + IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + InputFile) + "'");
throw new Exception("Error - file not found. Could find file named '" + IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + inputFile) + "'");
return tempDir;
}
}
/// <summary>
/// Imports the specified package
/// </summary>
/// <param name="inputFile">Filename of the umbracopackage</param>
/// <returns></returns>
public string Import(string inputFile)
{
return Import(inputFile, true);
}
public int CreateManifest(string tempDir, string guid, string repoGuid)
@@ -713,7 +725,8 @@ namespace umbraco.cms.businesslogic.packager
return path + fileName;
return path + Path.DirectorySeparatorChar + fileName;
}
private static string UnPack(string zipName)
private static string UnPack(string zipName, bool deleteFile)
{
// Unzip
@@ -762,7 +775,12 @@ namespace umbraco.cms.businesslogic.packager
// Clean up
s.Close();
File.Delete(zipName);
if (deleteFile)
{
File.Delete(zipName);
}
return tempDir;