Beispiel #1
0
 public static void Dereference(this Manifest manifest, string manifestFolder)
 {
     if (manifest == null)
     {
         throw new ArgumentNullException(nameof(manifest));
     }
     if (manifestFolder == null)
     {
         throw new ArgumentNullException(nameof(manifestFolder));
     }
     FileWriterBase.EnsureFolder(manifestFolder);
     lock (manifest)
     {
         var ofiList = (from f in manifest.Files
                        from ofi in f.OutputFiles.Values
                        where ofi.LinkToPath != null
                        select ofi).ToList();
         if (ofiList.Count == 0)
         {
             return;
         }
         var fal = FileAbstractLayerBuilder.Default
                   .ReadFromManifest(manifest, manifestFolder)
                   .WriteToRealFileSystem(manifestFolder)
                   .Create();
         foreach (var rp in ofiList)
         {
             fal.Copy(rp.RelativePath, rp.RelativePath);
         }
         foreach (var ofi in ofiList)
         {
             ofi.LinkToPath = null;
         }
     }
 }
        public static void Dereference(this Manifest manifest, string manifestFolder, int parallelism)
        {
            if (manifest == null)
            {
                throw new ArgumentNullException(nameof(manifest));
            }
            if (manifestFolder == null)
            {
                throw new ArgumentNullException(nameof(manifestFolder));
            }
            FileWriterBase.EnsureFolder(manifestFolder);
            var fal = FileAbstractLayerBuilder.Default
                      .ReadFromManifest(manifest, manifestFolder)
                      .WriteToRealFileSystem(manifestFolder)
                      .Create();

            Parallel.ForEach(
                from f in manifest.Files
                from ofi in f.OutputFiles.Values
                where ofi.LinkToPath != null
                select ofi,
                new ParallelOptions {
                MaxDegreeOfParallelism = parallelism
            },
                ofi =>
            {
                try
                {
                    fal.Copy(ofi.RelativePath, ofi.RelativePath);
                    ofi.LinkToPath = null;
                }
                catch (PathTooLongException)
                {
                    Logger.LogError($"Unable to dereference file: {ofi.RelativePath}.", file: ofi.RelativePath);
                }
            });
        }