public static async Task sync(PathChange change) { var reader = change.ReadFileSystem; var sourceInfo = reader.query(change.Source); var targetInfo = reader.query(change.Target); var sourceKind = sourceInfo.Type; var targetKind = targetInfo.Type; if (sourceKind == PathType.NotExisting && targetKind == PathType.NotExisting) { change.log("not existing"); return; } if (sourceKind == PathType.Ignored || targetKind == PathType.Ignored) { change.log("ignored"); return; } if (targetKind == PathType.NotExisting) { if (change.Location == ChangeLocation.AtTarget) deleteSource(change, sourceKind); else await copyToTarget(change, sourceKind); return; } if (sourceKind == PathType.NotExisting) { if (change.Location == ChangeLocation.AtSource) deleteTarget(change, targetKind); else await copyToSource(change, targetKind); return; } if (sourceKind != targetKind) { change.log("directory <-> file sync not implemented"); return; } if (sourceKind == PathType.Directory) await DirectorySynchronizer.syncDirectory(change); else await FileSynchronizer.syncFile(change, sourceInfo, targetInfo); }
public static void createDirectory(PathChange change, string path) { change.log("creating directory"); change.WriteFileSystem.createDirectory(path); }
public static async Task overwriteFile(PathChange change, string source, string target) { change.log("overwriting"); await change.WriteFileSystem.overwriteAsync(source, target); }
// we probably should copy the files by hand to ensure that the proper sharing flags are set. public static async Task copyFile(PathChange change, string source, string target) { change.log("copying"); await change.WriteFileSystem.copyAsync(source, target); }