private void EvaluateLocallyAbsentFilesAndDirs(SyncedDirectory syncedDirectory) { //evaluate the files first (needed to evaluate the dir) foreach (var syncedFile in syncedDirectory.Files.Where(x => x.LocallyAbsent && !x.RemoteDeleted).ToArray()) { //if this file was present on the last sync, it's really deleted, otherwise it is new on the remote side syncedFile.LocallyDeleted = syncedFile.TimestampOnLastSync.Local.HasValue; if (!syncedFile.LocallyDeleted) { //remote new, construct local directory syncedFile.LocalDirectory = Path.Combine(_fileRepository.StorageDirectory, syncedDirectory.GetRelativePath()); } } if (syncedDirectory.LocallyAbsent) { var shouldLive = syncedDirectory.Files.Any(x => !x.LocallyDeleted); syncedDirectory.LocallyDeleted = !shouldLive; } foreach (var subDir in syncedDirectory.SubDirectories) { EvaluateLocallyAbsentFilesAndDirs(subDir); } }
/// <summary> /// returns path relative to the root of this tree, so the first node ('PersonalWiki') won't be evaluated. /// </summary> /// <returns></returns> public string GetRelativePath() { if (_parent == null) { //this is the root node return(string.Empty); } //this is a subdir var parentPath = _parent.GetRelativePath(); if (!string.IsNullOrEmpty(parentPath)) { parentPath += "/"; } return(parentPath + Name); }