From d8c183df256c94b5697dc8efc426cff0c167ea87 Mon Sep 17 00:00:00 2001 From: Ramil_Algayev Date: Sat, 4 Jan 2025 20:20:42 +0400 Subject: [PATCH] fixed small bug with updating --- src/data.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/data.rs b/src/data.rs index 0f09021..95cd4e5 100644 --- a/src/data.rs +++ b/src/data.rs @@ -263,8 +263,12 @@ impl BrainData { contract.disk_size_gb = updatevmreq.0.disk_size_gb; contract.vcpus = updatevmreq.0.vcpus; contract.memory_mb = updatevmreq.0.memory_mb; - contract.kernel_sha = updatevmreq.0.kernel_sha; - contract.dtrfs_sha = updatevmreq.0.dtrfs_sha; + if !updatevmreq.0.kernel_sha.is_empty() { + contract.kernel_sha = updatevmreq.0.kernel_sha; + } + if !updatevmreq.0.dtrfs_sha.is_empty() { + contract.dtrfs_sha = updatevmreq.0.dtrfs_sha; + } contract.updated_at = Utc::now().to_rfc3339(); } } @@ -274,9 +278,7 @@ impl BrainData { mut req: grpc::NewVmReq, tx: OneshotSender, ) { - if req.uuid.is_empty() { - req.uuid = uuid::Uuid::new_v4().to_string(); - } + req.uuid = uuid::Uuid::new_v4().to_string(); info!("Inserting new vm request in memory: {req:?}"); self.tmp_newvm_reqs .insert(req.uuid.clone(), (req.clone(), tx));