From 3b1992e647bc2b3b17fc328df091956766f8fdfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Cortier?= Date: Fri, 4 Aug 2023 04:17:34 -0400 Subject: [PATCH] fix(dgw): error 500 when recording folder is missing (#502) When listing the recordings, if the recording directory does not exist, it means that there is no recording yet (and the folder will be created later). However, Devolutions Gateway is attempting to read this folder anyway and the HTTP error 500 (Internal Server Error) is returned. This patch fixes this by returning an empty list as appropriate. Issue: DGW-99 --- devolutions-gateway/src/api/jrec.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/devolutions-gateway/src/api/jrec.rs b/devolutions-gateway/src/api/jrec.rs index 86a0dca93..6fde6a118 100644 --- a/devolutions-gateway/src/api/jrec.rs +++ b/devolutions-gateway/src/api/jrec.rs @@ -129,8 +129,15 @@ pub(crate) async fn list_recordings( _scope: RecordingsReadScope, ) -> Result>, HttpError> { let conf = conf_handle.get_conf(); - let dirs = list_uuid_dirs(conf.recording_path.as_std_path()) - .map_err(HttpError::internal().with_msg("failed recording listing").err())?; + let recording_path = conf.recording_path.as_std_path(); + + let dirs = if recording_path.exists() { + list_uuid_dirs(recording_path).map_err(HttpError::internal().with_msg("failed recording listing").err())? + } else { + // If the recording directory does not exist, it means that there is no recording yet + Vec::new() + }; + Ok(Json(dirs)) }