コード例 #1
0
        public static ManifestDigest GenerateDigest([NotNull] string path, [NotNull] ITaskHandler handler, [CanBeNull] IStore keepDownloads = null)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }
            #endregion

            var digest = new ManifestDigest();

            // Generate manifest for each available format...
            foreach (var format in ManifestFormat.All)
            // ... and add the resulting digest to the return value
            {
                var generator = new ManifestGenerator(path, format);
                handler.RunTask(generator);
                digest.ParseID(generator.Manifest.CalculateDigest());
            }

            if (digest.PartialEquals(ManifestDigest.Empty))
            {
                Log.Warn(Resources.EmptyImplementation);
            }

            if (keepDownloads != null)
            {
                try
                {
                    keepDownloads.AddDirectory(path, digest, handler);
                }
                catch (ImplementationAlreadyInStoreException)
                {}
            }

            return(digest);
        }
コード例 #2
0
 /// <summary>
 /// Applies a <see cref="Recipe"/> and sends the result to the <see cref="_store"/>.
 /// </summary>
 /// <param name="recipe">The recipe to apply.</param>
 /// <param name="files">The files downloaded for the <paramref name="recipe"/> steps, order matching the <see cref="DownloadRetrievalMethod"/> steps in <see cref="Recipe.Steps"/>.</param>
 /// <param name="manifestDigest">The digest the result of the recipe should produce.</param>
 /// <exception cref="OperationCanceledException">An IO task was canceled from another thread.</exception>
 /// <exception cref="NotSupportedException">A file format, protocal, etc. is unknown or not supported.</exception>
 /// <exception cref="IOException">A downloaded file could not be written to the disk or extracted.</exception>
 /// <exception cref="ImplementationAlreadyInStoreException">There is already an <see cref="Implementation"/> with the specified <paramref name="manifestDigest"/> in the store.</exception>
 /// <exception cref="UnauthorizedAccessException">Write access to <see cref="IStore"/> is not permitted.</exception>
 /// <exception cref="DigestMismatchException">An <see cref="Implementation"/>'s <see cref="Archive"/>s don't match the associated <see cref="ManifestDigest"/>.</exception>
 private void ApplyRecipe([NotNull] Recipe recipe, [NotNull, ItemNotNull] IEnumerable <TemporaryFile> files, ManifestDigest manifestDigest)
 {
     using (var recipeDir = recipe.Apply(files, Handler, manifestDigest))
         _store.AddDirectory(recipeDir, manifestDigest, Handler);
 }