private void HandleAdds(VaultClientFolder folder, ChangeSetItemColl changes) { var versionedFiles = new HashSet <string>(); GetAllVersionedFiles(folder, versionedFiles); var versionedDiskPaths = versionedFiles.Select(MakeDiskPath).ToList(); var filesToAdd = new HashSet <string>(Directory.GetFiles(_workingFolder, "*", SearchOption.AllDirectories)); filesToAdd.ExceptWith(versionedDiskPaths); var dirToFiles = new Dictionary <string, HashSet <string> >(); foreach (var file in filesToAdd) { var dir = Path.GetDirectoryName(file); dir = dir.Substring(Math.Min(_workingFolder.Length + 1, dir.Length)); if (!dirToFiles.TryGetValue(dir, out var files)) { files = new HashSet <string>(); dirToFiles[dir] = files; } files.Add(file); } foreach (var pair in dirToFiles) { var dir = pair.Key; var files = pair.Value; var repoFolder = string.IsNullOrEmpty(dir) ? _repoFolder : $"{_repoFolder}/{dir}"; repoFolder = repoFolder.Replace('\\', '/'); changes.AddRange(ServerOperations.ProcessCommandAdd(repoFolder, files.ToArray())); } }