From cfafabc3d82c1e3f96a2bbe8205d06cb9610b51c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 18 Apr 2024 22:22:16 +0200 Subject: [PATCH 1/4] Fix success detection --- src/rentry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rentry.rs b/src/rentry.rs index 58ee54c..e9496f4 100644 --- a/src/rentry.rs +++ b/src/rentry.rs @@ -150,7 +150,7 @@ pub fn edit_paste( if res.status().is_redirection() { let location = res.headers().get("Location").unwrap().to_str().unwrap(); - if location == "/" { + if location == "/".to_owned() + paste_name { return Ok(()); } } From 939ae84a105f904a53cfcb0b349bc42890ea9b06 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 18 Apr 2024 22:22:34 +0200 Subject: [PATCH 2/4] Better success msg --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 879e63c..1183048 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,7 @@ fn main() { while let Some(edit_code) = edit_codes.next() { match edit_paste(&client, &csrf_data, &edit_code, PASTE_NAME) { Ok(_) => { - println!("Paste deleted successfully with edit code: {edit_code}"); + println!("Success, found edit code: {edit_code}"); return; } Err(e) => match e { From 9ec4d318139eded412dc6aaf51e13e5a22c05af9 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 18 Apr 2024 22:22:16 +0200 Subject: [PATCH 3/4] Fix success detection --- src/rentry.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/rentry.rs b/src/rentry.rs index 58ee54c..fc4e7cd 100644 --- a/src/rentry.rs +++ b/src/rentry.rs @@ -85,11 +85,6 @@ impl From for EditError { if status.is_redirection() { let location = headers.get("Location").unwrap().to_str().unwrap(); - if location == "/" { - // This is supposed to be handled from delete_paste function, - // This is an error enum, we can't represent success - panic!("response is successfult"); - } return Self::UnexpectedRedirect(location.to_string()); } @@ -150,7 +145,7 @@ pub fn edit_paste( if res.status().is_redirection() { let location = res.headers().get("Location").unwrap().to_str().unwrap(); - if location == "/" { + if location == "/".to_owned() + paste_name { return Ok(()); } } From d5dd28b4e58045d119c01ccff690aa4e199c2360 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 18 Apr 2024 22:22:34 +0200 Subject: [PATCH 4/4] Better success msg --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 879e63c..1183048 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,7 @@ fn main() { while let Some(edit_code) = edit_codes.next() { match edit_paste(&client, &csrf_data, &edit_code, PASTE_NAME) { Ok(_) => { - println!("Paste deleted successfully with edit code: {edit_code}"); + println!("Success, found edit code: {edit_code}"); return; } Err(e) => match e {