Exemple #1
0
        private async Task <Recipe> UnpackArchiveAsync(string tempPath, Stream packageFile)
        {
            // Unpack the zip file into the package directory
            var tempPackagePath = Path.Combine(tempPath, Constants.StorePackageFolderName);

            Directory.CreateDirectory(tempPackagePath);
            await PackageManager.ExtractAsync(packageFile, tempPackagePath);

            // Load the packages recipe file
            var recipe = await RecipeManager.LoadFromFileAsync(tempPackagePath);

            var packagePath = PackageManager.BuildKitchenPackagePath(_config, recipe);

            // TODO : Perform some verification that the package is valid

            // TODO : Should not hit this when, verify the package exists before download
            // For now delete and recreate it
            if (Directory.Exists(packagePath))
            {
                Directory.Delete(packagePath, true);
            }

            // Ensure the parent directory exists
            var packageParentDirectory = Directory.GetParent(packagePath);

            if (!packageParentDirectory.Exists)
            {
                packageParentDirectory.Create();
            }

            // Move the results out of the staging directory
            Directory.Move(tempPackagePath, packagePath);

            return(recipe);
        }