/// <summary> /// Sets the <see cref="ManifestDigest"/> in the <see cref="ContainerRef"/>. /// </summary> /// <param name="digest">The digest to set.</param> /// <param name="executor">Used to apply properties in an undoable fashion.</param> private void SetDigest(ManifestDigest digest, ICommandExecutor executor) { executor.Execute(new SetValueCommand <ManifestDigest>(() => ContainerRef.ManifestDigest, value => ContainerRef.ManifestDigest = value, digest)); if (string.IsNullOrEmpty(ContainerRef.ID) || ContainerRef.ID.Contains(@"=")) { executor.Execute(new SetValueCommand <string>(() => ContainerRef.ID, value => ContainerRef.ID = value, @"sha1new=" + digest.Sha1New)); } }
/// <summary> /// Generates the <see cref="ManifestDigest"/> for the files specified in the <see cref="RetrievalMethod"/>. /// </summary> /// <param name="handler">A callback object used when the the user is to be informed about progress.</param> /// <param name="executor">Used to apply properties in an undoable fashion.</param> /// <returns>The newly generated digest.</returns> private ManifestDigest GenerateDigest(ITaskHandler handler, ICommandExecutor executor) { ManifestDigest digest; using (var tempDir = Target.DownloadAndApply(handler, executor)) digest = ImplementationUtils.GenerateDigest(tempDir, handler); if (digest.PartialEquals(ManifestDigest.Empty)) { Msg.Inform(this, Resources.EmptyImplementation, MsgSeverity.Warn); } return(digest); }
/// <summary> /// Checks whether the <see cref="ManifestDigest"/> in <see cref="ContainerRef"/> matches the value generated by <see cref="GenerateDigest"/>. /// </summary> /// <param name="handler">A callback object used when the the user is to be informed about progress.</param> /// <param name="executor">Used to apply properties in an undoable fashion.</param> private void CheckDigest(ITaskHandler handler, ICommandExecutor executor) { var digest = GenerateDigest(handler, executor); if (ContainerRef.ManifestDigest == default(ManifestDigest)) { SetDigest(digest, executor); } else if (digest != ContainerRef.ManifestDigest) { bool warnOtherImplementations = (ContainerRef.RetrievalMethods.Count > 1); if (Msg.YesNo(this, warnOtherImplementations ? Resources.DigestMismatch + "\n" + Resources.DigestOtherImplementations : Resources.DigestMismatch, warnOtherImplementations ? MsgSeverity.Warn : MsgSeverity.Info, Resources.DigestReplace, Resources.DigestKeep)) { SetDigest(digest, executor); } } }