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};
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);
}
} 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)