public string Download(string path, string artifactUri) { var tempPath = this.DownloadToTemp(artifactUri); if (string.IsNullOrEmpty(tempPath) || !FileHelper.FileMove(tempPath, path, true)) { return(string.Empty); } return(path); }
private UpdateLocalVersion ProcessRename(GetOperation operation, ProcessDirection processDirection, IProgressMonitor monitor) { //If the operation is called by Repository OnMoveFile or OnMoveDirectory file/folder is moved before this method. //When is called by Source Exporer or By Revert command file is not moved bool hasBeenMoved = !FileHelper.Exists(operation.SourceLocalItem) && FileHelper.Exists(operation.TargetLocalItem); if (!hasBeenMoved) { var found = false; if (operation.ItemType == ItemType.File) { var project = IdeApp.Workspace.GetProjectContainingFile(operation.SourceLocalItem); if (project != null) { found = true; FileHelper.FileMove(operation.SourceLocalItem, operation.TargetLocalItem); this.ProjectMoveFile(project, operation.SourceLocalItem, operation.TargetLocalItem); project.Save(monitor); } } else { var project = FindProjectContainingFolder(operation.SourceLocalItem); if (project != null) { found = true; FileHelper.FolderMove(operation.SourceLocalItem, operation.TargetLocalItem); this.ProjectMoveFolder(project, operation.SourceLocalItem, operation.TargetLocalItem); project.Save(monitor); } } if (!found) { if (operation.ItemType == ItemType.File) { FileHelper.FileMove(operation.SourceLocalItem, operation.TargetLocalItem); } else if (operation.ItemType == ItemType.Folder) { FileHelper.FolderMove(operation.SourceLocalItem, operation.TargetLocalItem); } } } return(new UpdateLocalVersion(operation.ItemId, operation.TargetLocalItem, operation.VersionServer)); }
public string DownloadToTempWithName(string downloadUri, string fileName) { var path = this.DownloadToTemp(downloadUri); if (File.Exists(path)) { var name = Path.GetFileName(fileName); var newName = Path.Combine(Path.GetDirectoryName(path), name); if (FileHelper.FileMove(path, newName, true)) { return(newName); } else { return(string.Empty); } } return(string.Empty); }