/// <summary> /// Converts the input file URL into proper http URL with SAS token, ready for batch to download. /// Removes the query strings from the input file path and the command script content. /// Uploads the file if content is provided. /// </summary> /// <param name="inputFile"><see cref="TesInput"/> file</param> /// <param name="taskId">TES task Id</param> /// <param name="queryStringsToRemoveFromLocalFilePaths">Query strings to remove from local file paths</param> /// <returns>List of modified <see cref="TesInput"/> files</returns> private async Task <TesInput> GetTesInputFileUrl(TesInput inputFile, string taskId, List <string> queryStringsToRemoveFromLocalFilePaths) { if (inputFile.Path != null && !inputFile.Path.StartsWith(CromwellPathPrefix, StringComparison.OrdinalIgnoreCase)) { throw new Exception($"Unsupported input path '{inputFile.Path}' for task Id {taskId}. Must start with '{CromwellPathPrefix}'."); } if (inputFile.Url != null && inputFile.Content != null) { throw new Exception("Input Url and Content cannot be both set"); } if (inputFile.Url == null && inputFile.Content == null) { throw new Exception("One of Input Url or Content must be set"); } if (inputFile.Type == TesFileType.DIRECTORYEnum) { throw new Exception("Directory input is not supported."); } string inputFileUrl; if (inputFile.Content != null || IsCromwellCommandScript(inputFile)) { inputFileUrl = await MapLocalPathToSasUrlAsync(inputFile.Path); var writableUrl = new Uri(await MapLocalPathToSasUrlAsync(inputFile.Path, getContainerSas: true)); var content = inputFile.Content ?? await azureProxy.DownloadBlobAsync(new Uri(inputFileUrl)); content = IsCromwellCommandScript(inputFile) ? RemoveQueryStringsFromLocalFilePaths(content, queryStringsToRemoveFromLocalFilePaths) : content; await azureProxy.UploadBlobAsync(writableUrl, content); } else if (inputFile.Url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { inputFileUrl = inputFile.Url; } else { var mappedUrl = await MapLocalPathToSasUrlAsync(inputFile.Url); if (mappedUrl != null) { inputFileUrl = mappedUrl; } else { throw new Exception($"Unsupported input URL '{inputFile.Url}' for task Id {taskId}. Must start with 'http', '{CromwellPathPrefix}' or use '/accountName/containerName/blobPath' pattern where TES service has Contributor access to the storage account."); } } var path = RemoveQueryStringsFromLocalFilePaths(inputFile.Path, queryStringsToRemoveFromLocalFilePaths); return(new TesInput { Url = inputFileUrl, Path = path }); }
/// <summary> /// Determines if the <see cref="TesInput"/> file is a Cromwell command script /// </summary> /// <param name="inputFile"><see cref="TesInput"/> file</param> /// <returns>True if the file is a Cromwell command script</returns> private static bool IsCromwellCommandScript(TesInput inputFile) { return(inputFile.Name.Equals("commandScript")); }