/// <summary> /// Executes <see cref="RegisterFilesForBuildManifestCommand"/>. Checks if Cache contains build manifest hashes for given <see cref="BuildManifestEntry"/>. /// Else checks if local files exist and computes their ContentHash. /// Returns an empty array on success. Any failing BuildManifestEntries are returned for logging. /// If build manifest hashes are not available, the files are materialized using <see cref="ExecuteMaterializeFileAsync"/>, the build manifest hashes are computed and stored into cache. /// </summary> private async Task <IIpcResult> ExecuteRecordBuildManifestHashesAsync(RegisterFilesForBuildManifestCommand cmd) { Contract.Requires(cmd != null); var tasks = cmd.BuildManifestEntries .Select(buildManifestEntry => ExecuteRecordBuildManifestHashWithXlgAsync(cmd.DropName, buildManifestEntry)) .ToArray(); var result = await TaskUtilities.SafeWhenAll(tasks); if (result.Any(value => !value.IsValid)) { BuildManifestEntry[] failures = result.Where(value => !value.IsValid) .Select(value => new BuildManifestEntry(value.RelativePath, value.AzureArtifactsHash, "Invalid", FileArtifact.Invalid)) // FullFilePath is unused by the caller .ToArray(); return(IpcResult.Success(cmd.RenderResult(failures))); } else { m_executionLog.RecordFileForBuildManifest(new Tracing.RecordFileForBuildManifestEventData(result.ToList())); return(IpcResult.Success(cmd.RenderResult(Array.Empty <BuildManifestEntry>()))); } }
/// <summary> /// Executes <see cref="RegisterFilesForBuildManifestCommand"/>. Checks if local files exist and computes their ContentHash. /// Else checks if Cache contains SHA-256 Hashes for given <see cref="BuildManifestEntry"/>. /// Returns an empty array on success. Any failing BuildManifestEntries are returned for logging. /// If SHA-256 ContentHashes do not exists, the files are materialized using <see cref="ExecuteMaterializeFileAsync"/>, the build manifest hashes are computed and stored into cache. /// </summary> private async Task <IIpcResult> ExecuteRecordBuildManifestHashesAsync(RegisterFilesForBuildManifestCommand cmd) { Contract.Requires(cmd != null); var tasks = cmd.BuildManifestEntries .Select(buildManifestEntry => ExecuteRecordBuildManifestHashAsync(cmd.DropName, buildManifestEntry)) .ToArray(); var result = await TaskUtilities.SafeWhenAll(tasks); BuildManifestEntry[] failedEntries = result.Where(value => value != null).ToArray(); return(IpcResult.Success(cmd.RenderResult(failedEntries))); }