From 33b0cd5a343f1a26009690b27fda682b2f038df0 Mon Sep 17 00:00:00 2001 From: Audionut Date: Sun, 12 Oct 2025 10:32:51 +1000 Subject: [PATCH] fix ftp append (#914) previously, the target file would always be unlinked upon upload resume, contrary to what the client expects (open for append). when a client sends an APPE, pyftpdlib will `ftp_STOR(file, "a")` which is something that should be allowed within the ftp-wt grace period --- copyparty/ftpd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/copyparty/ftpd.py b/copyparty/ftpd.py index 5482436b..cc7dde25 100644 --- a/copyparty/ftpd.py +++ b/copyparty/ftpd.py @@ -251,7 +251,7 @@ class FtpFs(AbstractedFS): if w and need_unlink: if td >= -1 and td <= self.args.ftp_wt: - # within permitted timeframe; unlink and accept + # within permitted timeframe; allow overwrite or resume do_it = True elif self.args.no_del or self.args.ftp_no_ow: # file too old, or overwrite not allowed; reject @@ -268,7 +268,9 @@ class FtpFs(AbstractedFS): if not do_it: raise FSE("File already exists") - wunlink(self.log, ap, VF_CAREFUL) + # Don't unlink file for append mode + elif "a" not in mode: + wunlink(self.log, ap, VF_CAREFUL) ret = open(fsenc(ap), mode, self.args.iobuf) if w and "fperms" in vfs.flags: