internal void Delete ( [Required, Description(GrpcPortDescription)] int grpcPort, [Required, Description(HashTypeDescription)] string hashType, [Required, Description("Content hash value of referenced content to place")] string hash ) { Initialize(); var context = new Interfaces.Tracing.Context(_logger); var operationContext = new OperationContext(context); try { Validate(); var ht = GetHashTypeByNameOrDefault(hashType); var contentHash = new ContentHash(ht, HexUtilities.HexToBytes(hash)); GrpcContentClient client = new GrpcContentClient( new ServiceClientContentSessionTracer(nameof(Delete)), _fileSystem, new ServiceClientRpcConfiguration(grpcPort), _scenario); var deleteResult = client.DeleteContentAsync(operationContext, contentHash, deleteLocalOnly: false).GetAwaiter().GetResult(); _tracer.Always(context, deleteResult.ToString()); } catch (Exception e) { _tracer.Error(context, e, $"Unhandled exception in {nameof(Application)}.{nameof(Delete)}"); } }
/// <inheritdoc /> public async Task <DeleteResult> DeleteFileAsync(OperationContext context, ContentHash hash, MachineLocation targetMachine) { (string host, int port) = ExtractHostInfo(targetMachine); using (var client = new GrpcContentClient( new ServiceClientContentSessionTracer(nameof(ServiceClientContentSessionTracer)), new PassThroughFileSystem(), new ServiceClientRpcConfiguration(port) { GrpcHost = host }, scenario: string.Empty)) { return(await client.DeleteContentAsync(context, hash, deleteLocalOnly : true)); } }
/// <inheritdoc /> public async Task <DeleteResult> DeleteFileAsync(OperationContext context, ContentHash hash, MachineLocation targetMachine) { var targetPath = new AbsolutePath(targetMachine.Path); var targetMachineName = targetPath.IsLocal ? "localhost" : targetPath.GetSegments()[0]; using (var client = new GrpcContentClient( new ServiceClientContentSessionTracer(nameof(ServiceClientContentSessionTracer)), new PassThroughFileSystem(), new ServiceClientRpcConfiguration(_grpcPort) { GrpcHost = targetMachineName }, scenario: string.Empty)) { return(await client.DeleteContentAsync(context, hash, deleteLocalOnly : true)); } }