From 8a83e4283513a57f33e6e8cd6f3c67a873ae3f8e Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sun, 16 Aug 2026 13:49:27 +0200 Subject: [PATCH] implement storing the content of a a new file note in the database in add_file_note --- application/backend/src/backend.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/application/backend/src/backend.rs b/application/backend/src/backend.rs index 87feda5..d5e8d61 100644 --- a/application/backend/src/backend.rs +++ b/application/backend/src/backend.rs @@ -42,7 +42,7 @@ use tokio::sync::{broadcast, mpsc}; use tokio::sync::broadcast::error::SendError; use migration::{Expr, Migrator, MigratorTrait}; -use entity::{collection, note, notecontent, profile, repository}; +use entity::{collection, filecontent, note, notecontent, profile, repository}; use entity::profile::Entity as Profile; use entity::collection::{create_notebook_hierarchy, CollectionType, Entity as Collection, Node}; use entity::note::{Column, Entity as Note, NoteType}; @@ -759,11 +759,7 @@ impl BackendHandle { Ok(RenameNoteRet::Ok) }.await; - let res = match result { - Ok(r) => r, - Err(e) => RenameNoteRet::Error(e) - }; - + let res = result.unwrap_or_else(|e| RenameNoteRet::Error(e)); callback(res); }); let _ = self.tx.send(cmd); @@ -849,7 +845,17 @@ impl BackendHandle { } } else { // copy note content to the database - // TODO + let data = match fs::read(pathbuf.as_path()).await { + Ok(data) => data, + Err(e) => return Err(DbErr::Custom(e.to_string())) + }; + + let file_content = filecontent::ActiveModel { + note_id: Set(model.note_id), + content: Set(data), + ..Default::default() + }; + let _ = file_content.insert(&bhandle.backend.db).await?; } Ok(model) -- 2.52.0