From 3cabbf03f80e78a69a0b9e797050a1dacf5c26da Mon Sep 17 00:00:00 2001
From: sherlock2010 <15151851377@163.com>
Date: Thu, 28 Oct 2021 18:36:53 +0800
Subject: [PATCH] Quit while source file increased

---
 src/FileCopy.cc | 7 +++++++
 src/FileCopy.h  | 1 +
 2 files changed, 8 insertions(+)

diff --git a/src/FileCopy.cc b/src/FileCopy.cc
index ead65a2..361958e 100644
--- a/src/FileCopy.cc
+++ b/src/FileCopy.cc
@@ -1137,6 +1137,7 @@ void FileCopyPeerFA::OpenSession()
 	 debug((10,"copy dst: seek past eof (seek_pos=%lld, size=%lld)\n",
 		  (long long)seek_pos,(long long)e_size));
 	 eof=true;
+	 fileincreased=true;
 	 if(date==NO_DATE || date==NO_DATE_YET)
 	    return;
       }
@@ -1284,6 +1285,11 @@ int FileCopyPeerFA::Put_LL(const char *buf,int len)
    if(session->IsClosed())
       OpenSession();
 
+   if(fileincreased)
+   {
+      SetError(_("file size increased during transfer"));
+      return -1;
+   }
    off_t io_at=pos; // GetRealPos can alter pos, save it.
    if(GetRealPos()!=io_at)
       return 0;
@@ -1352,6 +1358,7 @@ void FileCopyPeerFA::Init()
 {
    get_delay=0;
    fxp=false;
+   fileincreased=false;
    redirections=0;
    can_seek=true;
    can_seek0=true;
diff --git a/src/FileCopy.h b/src/FileCopy.h
index af97880..5a9e4cf 100644
--- a/src/FileCopy.h
+++ b/src/FileCopy.h
@@ -335,6 +335,7 @@ class FileCopyPeerFA : public FileCopyPeer
    FileSet info;
 
    bool fxp;   // FXP (ftp<=>ftp copy) active
+   bool fileincreased;
 
    UploadState upload_state;
    int redirections;
-- 
1.8.3.1

