Exemplo n.º 1
0
        /// <summary>
        /// Finds objects of the same name, but different hashes
        /// </summary>
        private static void FindModifieds(ChangelogBuilder changelog, string prefix, VDKeyedCollection byName,
                                          VDKeyedCollection otherByName)
        {
            var toRemove = new LinkedList <string>();

            foreach (var otherVD in otherByName)
            {
                //if (byName.ContainsKey(pair.Key))
                if (byName.Contains(otherVD.Filename))
                {
                    VersionData thisVD = byName[otherVD.Filename];
                    if (otherVD.Filetype == thisVD.Filetype)
                    {
                        string fpath = PrefixFilename(prefix, otherVD.Filename);
                        changelog.Modify(fpath, otherVD.Hash);
                        if (otherVD.Filetype == FileType.Directory)
                        {
                            var subchangelog = BuildChangelog(thisVD, otherVD, fpath);
                            changelog.Aggregate(subchangelog);
                        }
                        toRemove.AddLast(otherVD.Filename);
                    }
                }
            }
            foreach (string s in toRemove)
            {
                byName.Remove(s);
                otherByName.Remove(s);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds all descendant files of a Directory to a changelog
 /// </summary>
 private static void AggregateAdd(ChangelogBuilder changelog, string prefix, VersionData update)
 {
     foreach (var child in update.Children)
     {
         string fpath = PrefixFilename(prefix, child.Filename);
         changelog.Add(fpath, child.Hash);
         if (child.Filetype == FileType.Directory)
         {
             var subchangelog = BuildChangelog(child, null, fpath);
             changelog.Aggregate(subchangelog);
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Removes all descendant files of a Directory to a changelog
 /// </summary>
 private static void AggregateRemove(ChangelogBuilder changelog, string prefix, VersionData original)
 {
     foreach (var child in original.Children)
     {
         string fpath = PrefixFilename(prefix, child.Filename);
         changelog.Remove(fpath);
         if (child.Filetype == FileType.Directory)
         {
             var subchangelog = BuildChangelog(child, null, fpath);
             changelog.Aggregate(subchangelog);
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Finds objects that exist in one collection but not the other
 /// </summary>
 private static void FindAddRemoveds(ChangelogBuilder changelog, string prefix, VDKeyedCollection byName,
                                     VDKeyedCollection otherByName)
 {
     foreach (var pair in byName)
     {
         string fpath = PrefixFilename(prefix, pair.Filename);
         changelog.Remove(fpath);
         if (pair.Filetype == FileType.Directory)
         {
             var subchangelog = BuildChangelog(pair, null, fpath);
             changelog.Aggregate(subchangelog);
         }
     }
     foreach (var pair in otherByName)
     {
         string fpath = PrefixFilename(prefix, pair.Filename);
         changelog.Add(fpath, pair.Hash);
         if (pair.Filetype == FileType.Directory)
         {
             var subchangelog = BuildChangelog(null, pair, fpath);
             changelog.Aggregate(subchangelog);
         }
     }
 }