From 95e2ba11364e2c606795f5c3fe7f08c1605c1bfa Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 7 Oct 2025 01:07:24 +0800 Subject: [PATCH] :bug: Fixes some issues in drive service --- DysonNetwork.Drive/Startup/BroadcastEventHandler.cs | 6 +++--- DysonNetwork.Drive/Storage/FileController.cs | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/DysonNetwork.Drive/Startup/BroadcastEventHandler.cs b/DysonNetwork.Drive/Startup/BroadcastEventHandler.cs index d3ac949..1f28b8f 100644 --- a/DysonNetwork.Drive/Startup/BroadcastEventHandler.cs +++ b/DysonNetwork.Drive/Startup/BroadcastEventHandler.cs @@ -41,7 +41,7 @@ public class BroadcastEventHandler( await js.EnsureStreamCreated("file_events", [FileUploadedEvent.Type]); var fileUploadedConsumer = await js.CreateOrUpdateConsumerAsync("file_events", - new ConsumerConfig("drive_file_uploaded_handler"), cancellationToken: stoppingToken); + new ConsumerConfig("drive_file_uploaded_handler") { MaxDeliver = 3 }, cancellationToken: stoppingToken); var accountDeletedTask = HandleAccountDeleted(accountEventConsumer, stoppingToken); var fileUploadedTask = HandleFileUploaded(fileUploadedConsumer, stoppingToken); @@ -75,8 +75,8 @@ public class BroadcastEventHandler( } catch (Exception ex) { - logger.LogError(ex, "Error processing FileUploadedEvent for file {FileId}", payload?.FileId); - await msg.NakAsync(cancellationToken: stoppingToken); + logger.LogError(ex, "Error processing FileUploadedEvent for file {FileId}", payload.FileId); + await msg.NakAsync(cancellationToken: stoppingToken, delay: TimeSpan.FromSeconds(60)); } } } diff --git a/DysonNetwork.Drive/Storage/FileController.cs b/DysonNetwork.Drive/Storage/FileController.cs index 2074e16..51b6c84 100644 --- a/DysonNetwork.Drive/Storage/FileController.cs +++ b/DysonNetwork.Drive/Storage/FileController.cs @@ -70,13 +70,11 @@ public class FileController( } } - return StatusCode(StatusCodes.Status503ServiceUnavailable, "File is being processed. Please try again later."); + return StatusCode(StatusCodes.Status400BadRequest, "File is being processed. Please try again later."); } if (!file.PoolId.HasValue) - { return StatusCode(StatusCodes.Status500InternalServerError, "File is in an inconsistent state: uploaded but no pool ID."); - } var pool = await fs.GetPoolAsync(file.PoolId.Value); if (pool is null)