Updated error message of unwrapping the Arc in import.rs and export.rs, now collection the file in export.rs into Vec instead of String
This commit is contained in:
parent
05c7f721ec
commit
207832be43
@ -6,7 +6,7 @@ use crate::{
|
||||
};
|
||||
use futures::TryStreamExt;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use serde_json::to_string_pretty;
|
||||
use serde_json::to_vec_pretty;
|
||||
use std::sync::Arc;
|
||||
use teloxide::{adaptors::Throttle, prelude::*, types::InputFile};
|
||||
use tokio::{sync::Mutex, task::spawn_blocking};
|
||||
@ -38,10 +38,14 @@ async fn get_master_pass(
|
||||
drop(master_pass);
|
||||
let mut accounts = match Arc::try_unwrap(accounts) {
|
||||
Ok(account) => account.into_inner(),
|
||||
Err(_) => unreachable!(),
|
||||
Err(_) => {
|
||||
return Err(crate::Error::msg(
|
||||
"Couldn't get accounts from Arc in export.rs",
|
||||
))
|
||||
}
|
||||
};
|
||||
accounts.sort_unstable_by(|this, other| this.name.cmp(&other.name));
|
||||
let json = to_string_pretty(&User { accounts })?;
|
||||
let json = to_vec_pretty(&User { accounts })?;
|
||||
let file = InputFile::memory(json).file_name("accounts.json");
|
||||
bot.send_document(msg.chat.id, file)
|
||||
.reply_markup(deletion_markup())
|
||||
|
@ -49,7 +49,11 @@ async fn get_master_pass(
|
||||
drop(master_pass);
|
||||
let failed = match Arc::try_unwrap(failed) {
|
||||
Ok(accounts) => accounts.into_inner(),
|
||||
Err(_) => unreachable!(),
|
||||
Err(_) => {
|
||||
return Err(crate::Error::msg(
|
||||
"Couldn't get accounts from Arc in import.rs",
|
||||
))
|
||||
}
|
||||
};
|
||||
let message = if failed.is_empty() {
|
||||
"Success".to_owned()
|
||||
@ -84,7 +88,7 @@ async fn get_document(
|
||||
}
|
||||
};
|
||||
match document.file_name {
|
||||
Some(ref name) if name.trim().ends_with(".json") => (),
|
||||
Some(ref name) if name.trim_end().ends_with(".json") => (),
|
||||
_ => {
|
||||
bot.send_message(msg.chat.id, "Invalid file name")
|
||||
.reply_markup(deletion_markup())
|
||||
|
Loading…
Reference in New Issue
Block a user