Compare commits
3 Commits
445cac2d8f
...
d7a0a6a3e5
Author | SHA1 | Date |
---|---|---|
|
d7a0a6a3e5 | |
|
e5c9ff3aed | |
|
d109e3f034 |
|
@ -163,11 +163,6 @@ async fn async_main() {
|
|||
match utils::get_videos(&rclient, i).await {
|
||||
Ok(videos) => {
|
||||
for j in videos {
|
||||
{
|
||||
if tmp_handled.lock().unwrap().contains(&j) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if nodl {
|
||||
let mut seen_videos = seen_videos.write().unwrap();
|
||||
if !seen_videos.contains(&j) {
|
||||
|
@ -175,6 +170,9 @@ async fn async_main() {
|
|||
}
|
||||
} else {
|
||||
{
|
||||
if tmp_handled.lock().unwrap().contains(&j) {
|
||||
continue;
|
||||
}
|
||||
let seen_videos = seen_videos.read().unwrap();
|
||||
if seen_videos.contains(&j) {
|
||||
continue;
|
||||
|
|
|
@ -612,14 +612,61 @@ pub async fn upload_worker(
|
|||
let total_size = file.seek(SeekFrom::End(0)).await.unwrap();
|
||||
file.seek(SeekFrom::Start(0)).await.unwrap();
|
||||
let parts = (total_size as f64 / (2000.0 * 1024.0 * 1024.0)).ceil() as usize;
|
||||
let current_position = 0;
|
||||
for i in 0..parts {
|
||||
let filename = if parts == 1 {
|
||||
video_filename.clone()
|
||||
} else {
|
||||
format!("{}.part{:02}", &video_filename, i)
|
||||
};
|
||||
let mut size = total_size - current_position;
|
||||
let message = tclient
|
||||
.send_message(
|
||||
&chat,
|
||||
InputMessage::text(&format!("Uploading {}...", &video_filename)),
|
||||
)
|
||||
.await;
|
||||
if let Err(ref err) = message {
|
||||
eprintln!("Failed to send uploading message: {:?}", err);
|
||||
let text = format!("{:#?}", err);
|
||||
let size = text.len();
|
||||
let mut stream = Cursor::new(text.into_bytes());
|
||||
match tclient
|
||||
.upload_stream(&mut stream, size, "failed-send-uploading.log".to_string())
|
||||
.await
|
||||
{
|
||||
Ok(uploaded) => {
|
||||
let message = InputMessage::text("Failed to send uploading message")
|
||||
.mime_type("text/plain")
|
||||
.file(uploaded);
|
||||
if let Err(err) = tclient.send_message(&chat, message).await {
|
||||
eprintln!(
|
||||
"Failed to send message about failing to send uploading message: {:?}",
|
||||
err
|
||||
);
|
||||
if let Err(err) = tclient.send_message(&chat, InputMessage::text("Failed to send message about failing to send uploading message, see logs")).await {
|
||||
eprintln!("Failed to send message about failing to send message about failing to send uploading message: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!(
|
||||
"Failed to upload logs about failing to send uploading message: {:?}",
|
||||
err
|
||||
);
|
||||
if let Err(err) = tclient
|
||||
.send_message(
|
||||
&chat,
|
||||
InputMessage::text(
|
||||
"Failed to upload logs about failing to send uploading message, see logs",
|
||||
),
|
||||
)
|
||||
.await
|
||||
{
|
||||
eprintln!("Failed to send message about failing to upload logs about failing to send uploading message: {:?}", err);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
let mut size = file.stream_position().await.unwrap();
|
||||
if size > 2000 * 1024 * 1024 {
|
||||
size = 2000 * 1024 * 1024;
|
||||
}
|
||||
|
@ -664,6 +711,50 @@ pub async fn upload_worker(
|
|||
}
|
||||
}
|
||||
};
|
||||
if let Ok(mut message) = message {
|
||||
if let Err(err) = message.delete().await {
|
||||
eprintln!("Failed to delete uploading message: {:?}", err);
|
||||
let text = format!("{:#?}", err);
|
||||
let size = text.len();
|
||||
let mut stream = Cursor::new(text.into_bytes());
|
||||
match tclient
|
||||
.upload_stream(&mut stream, size, "failed-delete-uploading.log".to_string())
|
||||
.await
|
||||
{
|
||||
Ok(uploaded) => {
|
||||
let message = InputMessage::text("Failed to delete uploading message")
|
||||
.mime_type("text/plain")
|
||||
.file(uploaded);
|
||||
if let Err(err) = tclient.send_message(&chat, message).await {
|
||||
eprintln!(
|
||||
"Failed to send message about failing to delete uploading message: {:?}",
|
||||
err
|
||||
);
|
||||
if let Err(err) = tclient.send_message(&chat, InputMessage::text("Failed to send message about failing to delete uploading message, see logs")).await {
|
||||
eprintln!("Failed to send message about failing to send message about failing to delete uploading message: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!(
|
||||
"Failed to upload logs about failing to delete uploading message: {:?}",
|
||||
err
|
||||
);
|
||||
if let Err(err) = tclient
|
||||
.send_message(
|
||||
&chat,
|
||||
InputMessage::text(
|
||||
"Failed to upload logs about failing to delete uploading message, see logs",
|
||||
),
|
||||
)
|
||||
.await
|
||||
{
|
||||
eprintln!("Failed to send message about failing to upload logs about failing to delete uploading message: {:?}", err);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
if success {
|
||||
if let Err(err) = remove_file(&video_filename) {
|
||||
|
|
Loading…
Reference in New Issue