/// <summary> /// Creates a ZIP archive containing the <see cref="InstallationDir"/>. /// </summary> /// <remarks>Sets <see cref="FeedBuilder.RetrievalMethod"/> and calls <see cref="FeedBuilder.CalculateDigest"/>.</remarks> /// <param name="archivePath">The path of the ZIP file to create.</param> /// <param name="archiveUrl">The URL where the ZIP file will be uploaded.</param> /// <param name="handler">A callback object used when the the user needs to be informed about IO tasks.</param> /// <exception cref="InvalidOperationException"><see cref="Diff"/> was not called or <see cref="FeedBuilder.MainCandidate"/> is not set.</exception> /// <exception cref="OperationCanceledException">The user canceled the operation.</exception> /// <exception cref="IOException">There was an error reading the installation files or writing the ZIP archive.</exception> /// <exception cref="UnauthorizedAccessException">Access to the file system was not permitted.</exception> public void CollectFiles([NotNull] string archivePath, [NotNull] Uri archiveUrl, [NotNull] ITaskHandler handler) { #region Sanity checks if (string.IsNullOrEmpty(archivePath)) { throw new ArgumentNullException("archivePath"); } if (archiveUrl == null) { throw new ArgumentNullException("archiveUrl"); } if (handler == null) { throw new ArgumentNullException("handler"); } #endregion if (InstallationDir == null) { throw new InvalidOperationException("Diff() must be called first."); } handler.RunTask(new CreateZip(InstallationDir, archivePath)); var archive = new Archive { Href = archiveUrl, MimeType = Archive.MimeTypeZip }; using (var tempDir = archive.LocalApply(archivePath, handler)) { _feedBuilder.ImplementationDirectory = tempDir; _feedBuilder.CalculateDigest(handler); } _feedBuilder.RetrievalMethod = archive; }
/// <summary> /// Creates a archive containing the <see cref="InstallationDir"/>. /// </summary> /// <remarks>Sets <see cref="FeedBuilder.RetrievalMethod"/> and calls <see cref="FeedBuilder.CalculateDigest"/>.</remarks> /// <param name="archivePath">The path of the archive file to create.</param> /// <param name="archiveUrl">The URL where the archive will be uploaded.</param> /// <param name="handler">A callback object used when the the user needs to be informed about IO tasks.</param> /// <exception cref="InvalidOperationException"><see cref="Diff"/> was not called or <see cref="FeedBuilder.MainCandidate"/> is not set.</exception> /// <exception cref="OperationCanceledException">The user canceled the task.</exception> /// <exception cref="IOException">There was an error reading the installation files or writing the archive.</exception> /// <exception cref="UnauthorizedAccessException">Access to the file system was not permitted.</exception> public void CollectFiles([NotNull] string archivePath, [NotNull] Uri archiveUrl, [NotNull] ITaskHandler handler) { #region Sanity checks if (string.IsNullOrEmpty(archivePath)) { throw new ArgumentNullException(nameof(archivePath)); } if (archiveUrl == null) { throw new ArgumentNullException(nameof(archiveUrl)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion if (InstallationDir == null) { throw new InvalidOperationException("Diff() must be called first."); } _feedBuilder.ImplementationDirectory = InstallationDir; _feedBuilder.CalculateDigest(handler); var mimeType = Archive.GuessMimeType(archivePath) ?? Archive.MimeTypeZip; using (var generator = ArchiveGenerator.Create(InstallationDir, archivePath, mimeType)) handler.RunTask(generator); _feedBuilder.RetrievalMethod = new Archive { Href = archiveUrl, MimeType = mimeType, Size = new FileInfo(archivePath).Length }; }
private void buttonNext_Click(object sender, EventArgs e) { using (var handler = new GuiTaskHandler(this)) { if (FileUtils.IsBreakoutPath(comboBoxExtract.Text)) { Msg.Inform(this, Resources.ArchiveBreakoutPath, MsgSeverity.Error); return; } _archive.Extract = comboBoxExtract.Text ?? ""; _feedBuilder.ImplementationDirectory = Path.Combine(_feedBuilder.TemporaryDirectory, FileUtils.UnifySlashes(_archive.Extract)); try { // Candidate detection is handled differently when captuing an installer if (_installerCapture == null) { _feedBuilder.DetectCandidates(handler); } _feedBuilder.CalculateDigest(handler); } #region Error handling catch (OperationCanceledException) { return; } catch (ArgumentException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } catch (IOException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } catch (UnauthorizedAccessException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } #endregion } if (_feedBuilder.ManifestDigest.PartialEquals(ManifestDigest.Empty)) { Msg.Inform(this, Resources.EmptyImplementation, MsgSeverity.Warn); return; } if (_feedBuilder.MainCandidate == null) { Msg.Inform(this, Resources.NoEntryPointsFound, MsgSeverity.Warn); return; } Next(); }
private void OnSingleFile() { Retrieve( new SingleFile { Href = textBoxDownloadUrl.Uri }, checkLocalCopy.Checked ? textBoxLocalPath.Text : null); _feedBuilder.ImplementationDirectory = _feedBuilder.TemporaryDirectory; using (var handler = new DialogTaskHandler(this)) { _feedBuilder.DetectCandidates(handler); _feedBuilder.CalculateDigest(handler); } if (_feedBuilder.MainCandidate == null) { throw new NotSupportedException(Resources.NoEntryPointsFound); } else { _feedBuilder.GenerateCommands(); pageDownload.NextPage = pageDetails; } }
private void OnSingleFile() { Retrieve(new SingleFile { Href = textBoxUrl.Uri }); _feedBuilder.ImplementationDirectory = _feedBuilder.TemporaryDirectory; using (var handler = new GuiTaskHandler(this)) { _feedBuilder.DetectCandidates(handler); _feedBuilder.CalculateDigest(handler); } if (_feedBuilder.MainCandidate == null) { Msg.Inform(this, Resources.NoEntryPointsFound, MsgSeverity.Warn); } else { AsSingleFile(); } }