Comments (5)
AFAIK you have to seek your file from the REST position first.
from suppaftp.
In which case ?
I'm already doing it to restart an upload, but regarding restarting a download, even if I seek
my local file to the last byte downloaded, the io::copy
I'm doing with the data_stream
appends the whole file at the end of what I already have, and not just the missing part. For exemple, if my local file contains "AB", and my remote file is "ABCDE", I will end with "ABABCDE" on my local one.
from suppaftp.
try with Write instead of copy
from suppaftp.
I didn't find any write
method with io
lib, and for fs
it erases the existing file anyway so I went for this piece of code, replacing the copy
lines:
let mut buf: Vec<u8> = Vec::with_capacity(remaining_bytes);
data_stream.read_to_end(&mut buf).await.unwrap();
file.write(&buf).await.unwrap();
But I'm not sure if I understood well what you were meaning with trying with Write instead.
Still, it puts in buf
the entire file, and since we store everything in memory the memory consumption becomes really high with big files with that.
from suppaftp.
After inspecting server side logs between FileZilla client and this crate, I found only 1 difference in the command order when doing REST.
FileZilla does PASV -> REST -> RETR
But your crate does REST -> PASV -> RETR
I made a temporary function in your code source to do a dirty test in order to reproduce FileZilla order, basically resume_transfer and retr_as_stream in a single function, and it worked !
pub async fn retr_as_stream_re<S: AsRef<str>>(
&mut self,
file_name: S,
offset: usize
) -> FtpResult<DataStream<T>> {
let addr = self.pasv().await?;
self.perform(Command::Rest(offset)).await?;
self.read_response(Status::RequestFilePending).await?;
self.perform(Command::Retr(file_name.as_ref().to_string())).await?;
let data_stream = TcpStream::connect(addr)
.await
.map_err(FtpError::ConnectionError)?;
self.read_response_in(&[Status::AboutToSend, Status::AlreadyOpen])
.await?;
Ok(DataStream::Tcp(data_stream))
}
I didn't test it for the upload, but I'm pretty sure that it's the same problem, since the code and command order are quite the same of what I saw.
If you could fix this it would be much appreciated ^^
Edit : RFC3659 document stipulates that
The REST command must be the last command issued before the data transfer command that is to cause a restarted, rather than a complete, file transfer. The effect of issuing a REST command at any other time is undefined. The server-PI may react to a badly positioned REST command by issuing an error response to the following command, not being a restartable data transfer command, or it may save the restart value and apply it to the next data transfer command, or it may silently ignore the inappropriate restart attempt.
Source : https://datatracker.ietf.org/doc/html/rfc3659#section-5.3
from suppaftp.
Related Issues (20)
- [BUG] - Ftp with TLS (native-tls) Not working HOT 4
- [QUESTION] - 522 SSL connection failed
- [Feature Request] - Build the docs with doc_cfg
- [BUG] - POSIX setgid/setuid/sticky bits not supported
- [Feature Request] - Better composability HOT 3
- [BUG] - FEAT in asyncFtpStream hangs
- [Feature Request] - Timeouts for active data connection acceptance HOT 1
- [QUESTION] - Is there a plan to support sftp HOT 1
- [BUG] - abort can be called without passing ownership to data_stream HOT 1
- [BUG] - list parser: SyntaxError on name that starts with 2 numbers HOT 1
- [Feature Request] - Implementation of SITE command HOT 2
- [QUESTION] - Potential timeout? Advice on correct usage.
- [BUG] - Active mode commands timeout HOT 4
- [QUESTION] - Does suppaftp support an explicit proxy?
- Which ports to open on the firewall? HOT 4
- [Feature Request] - Make function `connect_with_stream` public
- [Feature Request] - Support MLST and MLSD HOT 3
- [BUG] - put_file does not work with Async SSL Native TLS HOT 3
- [BUG] - The file.log upload to ftp server. then lost \n line breaks HOT 1
- [QUESTION] - Can't connect, no TLS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from suppaftp.