diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-10-08 08:37:01 +0200 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2014-10-08 08:37:01 +0200 |
commit | 0c158e03ceb509a08d3d4ded79c3151237f669dd (patch) | |
tree | dc7a5cf8f15a7907d00beb75b5fa4d246ec3d36a /methods/ftp.cc | |
parent | a943fbf21ca0b9b58b8f1492fc518679b1d7c749 (diff) | |
parent | f2b47ba290f3a178c584da83f007cf0f720baabb (diff) |
Merge remote-tracking branch 'mvo/feature/expected-size' into debian/experimental
Diffstat (limited to 'methods/ftp.cc')
-rw-r--r-- | methods/ftp.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/methods/ftp.cc b/methods/ftp.cc index ac76295f0..5b739ea06 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -849,7 +849,8 @@ bool FTPConn::Finalize() /* This opens a data connection, sends REST and RETR and then transfers the file over. */ bool FTPConn::Get(const char *Path,FileFd &To,unsigned long long Resume, - Hashes &Hash,bool &Missing) + Hashes &Hash,bool &Missing, unsigned long long MaximumSize, + pkgAcqMethod *Owner) { Missing = false; if (CreateDataFd() == false) @@ -922,7 +923,14 @@ bool FTPConn::Get(const char *Path,FileFd &To,unsigned long long Resume, { Close(); return false; - } + } + + if (MaximumSize > 0 && To.Tell() > MaximumSize) + { + Owner->SetFailReason("MaximumSizeExceeded"); + return _error->Error("Writing more data than expected (%llu > %llu)", + To.Tell(), MaximumSize); + } } // All done @@ -1063,7 +1071,7 @@ bool FtpMethod::Fetch(FetchItem *Itm) FailFd = Fd.Fd(); bool Missing; - if (Server->Get(File,Fd,Res.ResumePoint,Hash,Missing) == false) + if (Server->Get(File,Fd,Res.ResumePoint,Hash,Missing,Itm->MaximumSize,this) == false) { Fd.Close(); |