diff --git a/src/hg_connect_http.rs b/src/hg_connect_http.rs index 530aa1178..57331cda5 100644 --- a/src/hg_connect_http.rs +++ b/src/hg_connect_http.rs @@ -43,7 +43,7 @@ use crate::libgit::{ credential_fill, curl_errorstr, die, get_active_slot, http_auth, http_follow_config, run_one_slot, slot_results, ssl_cainfo, HTTP_OK, HTTP_REAUTH, }; -use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt, SeekExt, SliceExt, ToBoxed}; +use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt, SliceExt, ToBoxed}; mod git_http_state { use std::ffi::CString; @@ -226,7 +226,7 @@ impl HttpRequest { curl_easy_setopt( slot.curl, CURLOPT_POSTFIELDSIZE_LARGE, - body.stream_len_().unwrap(), + body.seek(SeekFrom::End(0)).unwrap(), ); /* Ensure we have no state from a previous attempt that failed because * of authentication (401). */ diff --git a/src/hg_connect_stdio.rs b/src/hg_connect_stdio.rs index 6d8294b48..1c3712264 100644 --- a/src/hg_connect_stdio.rs +++ b/src/hg_connect_stdio.rs @@ -23,7 +23,7 @@ use crate::hg_connect::{ use crate::libc::FdFile; use crate::libcinnabar::{hg_connect_stdio, stdio_finish}; use crate::libgit::child_process; -use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt, SeekExt}; +use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt}; pub struct HgStdioConnection { capabilities: HgCapabilities, @@ -113,7 +113,7 @@ impl HgWireConnection for HgStdioConnection { self.proc_in.write_all(&header).unwrap(); drop(header); - let len = input.stream_len_().unwrap(); + let len = input.metadata().unwrap().len(); //TODO: chunk in smaller pieces. writeln!(self.proc_in, "{}", len).unwrap(); diff --git a/src/util.rs b/src/util.rs index 8dafdced4..4ccd2b793 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::ffi::{CStr, CString, OsStr}; -use std::io::{self, LineWriter, Read, Seek, SeekFrom, Write}; +use std::io::{self, LineWriter, Read, Write}; #[cfg(unix)] use std::os::unix::ffi; #[cfg(windows)] @@ -94,17 +94,6 @@ pub trait ReadExt: Read { impl ReadExt for T {} -pub trait SeekExt: Seek { - fn stream_len_(&mut self) -> io::Result { - let old_pos = self.stream_position()?; - let len = self.seek(SeekFrom::End(0))?; - self.seek(SeekFrom::Start(old_pos))?; - Ok(len) - } -} - -impl SeekExt for T {} - pub trait SliceExt { fn splitn_exact(&self, c: C) -> Option<[&Self; N]>; fn rsplitn_exact(&self, c: C) -> Option<[&Self; N]>;