protected override Task <IActionResult> CreateDirectoryPutResponse(DirectoryInfoBase info, string localFilePath) { var zipArchive = new ZipArchive(Request.Body, ZipArchiveMode.Read); zipArchive.Extract(localFilePath); PermissionHelper.ChmodRecursive("777", localFilePath, _tracer, TimeSpan.FromSeconds(30)); return(Task.FromResult((IActionResult)Ok())); }
private Task LocalZipFetch(IRepository repository, DeploymentInfoBase deploymentInfo, string targetBranch, ILogger logger, ITracer tracer) { var zipDeploymentInfo = (ZipDeploymentInfo)deploymentInfo; // For this kind of deployment, RepositoryUrl is a local path. var sourceZipFile = zipDeploymentInfo.RepositoryUrl; var extractTargetDirectory = repository.RepositoryPath; var info = FileSystemHelpers.FileInfoFromFileName(sourceZipFile); var sizeInMb = (info.Length / (1024f * 1024f)).ToString("0.00", CultureInfo.InvariantCulture); var message = String.Format( CultureInfo.InvariantCulture, "Cleaning up temp folders from previous zip deployments and extracting pushed zip file {0} ({1} MB) to {2}", info.FullName, sizeInMb, extractTargetDirectory); logger.Log(message); using (tracer.Step(message)) { // If extractTargetDirectory already exists, rename it so we can delete it concurrently with // the unzip (along with any other junk in the folder) var targetInfo = FileSystemHelpers.DirectoryInfoFromDirectoryName(extractTargetDirectory); if (targetInfo.Exists) { var moveTarget = Path.Combine(targetInfo.Parent.FullName, Path.GetRandomFileName()); targetInfo.MoveTo(moveTarget); } DeleteFilesAndDirsExcept(sourceZipFile, extractTargetDirectory, tracer); FileSystemHelpers.CreateDirectory(extractTargetDirectory); using (var file = info.OpenRead()) using (var zip = new ZipArchive(file, ZipArchiveMode.Read)) { deploymentInfo.repositorySymlinks = zip.Extract(extractTargetDirectory, preserveSymlinks: ShouldPreserveSymlinks()); CreateZipSymlinks(deploymentInfo.repositorySymlinks, extractTargetDirectory); PermissionHelper.ChmodRecursive("777", extractTargetDirectory, tracer, TimeSpan.FromMinutes(1)); } } CommitRepo(repository, zipDeploymentInfo); return(Task.CompletedTask); }