silver-ymz commented on code in PR #2192:
URL:
https://github.com/apache/incubator-opendal/pull/2192#discussion_r1187014514
##########
core/src/services/sftp/writer.rs:
##########
@@ -15,31 +15,38 @@
// specific language governing permissions and limitations
// under the License.
+use std::time::Duration;
+
use async_trait::async_trait;
-use bb8::PooledConnection;
use bytes::Bytes;
+use openssh_sftp_client::file::File;
+use tokio::time::sleep;
-use super::backend::Manager;
use crate::raw::oio;
use crate::{Error, ErrorKind, Result};
pub struct SftpWriter {
- conn: PooledConnection<'static, Manager>,
- path: String,
+ file: File,
}
impl SftpWriter {
- pub fn new(conn: PooledConnection<'static, Manager>, path: String) -> Self
{
- SftpWriter { conn, path }
+ pub fn new(file: File) -> Self {
+ SftpWriter { file }
}
}
#[async_trait]
impl oio::Write for SftpWriter {
async fn write(&mut self, bs: Bytes) -> Result<()> {
- let mut file = self.conn.sftp.create(&self.path).await?;
-
- file.write_all(&bs).await?;
+ tokio::select! {
Review Comment:
The `File` will close automatically when `SftpWriter` is droped. And we
cannot move out `File` here. So I think we can ignore it here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]