/// <summary> /// cleans up the folder, so if someone renames a things /// (and we are using the name in the file) this will /// clean anything else in the folder that has that key /// </summary> protected void CleanUp(TObject item, string newFile, string folder) { var physicalFile = syncFileService.GetAbsPath(newFile); var files = syncFileService.GetFiles(folder, "*.config"); foreach (string file in files) { if (!file.InvariantEquals(physicalFile)) { var node = syncFileService.LoadXElement(file); if (node.GetKey() == item.Key) { var attempt = serializer.SerializeEmpty(item, SyncActionType.Rename, node.GetAlias()); if (attempt.Success) { syncFileService.SaveXElement(attempt.Item, file); } } } } var folders = syncFileService.GetDirectories(folder); foreach (var children in folders) { CleanUp(item, newFile, children); } }
public bool CheckVersionFile(string folder) { var versionFile = Path.Combine(syncFileService.GetAbsPath(folder), "usync.config"); if (!syncFileService.FileExists(versionFile)) { return(false); } else { try { var node = syncFileService.LoadXElement(versionFile); var format = node.Attribute("format").ValueOrDefault(""); if (!format.InvariantEquals(uSyncConstants.FormatVersion)) { var expectedVersion = SemVersion.Parse(uSyncConstants.FormatVersion); if (SemVersion.TryParse(format, out SemVersion current)) { if (current.CompareTo(expectedVersion) >= 0) { return(true); } } return(false); } } catch { return(false); } } return(true); }