bpo-40105: ZipFile truncate in append mode with shorter comment (GH-19337)

(cherry picked from commit ff9147d93b868f0e13b9fe14e2a76c2879f6787b)

Co-authored-by: Jan Mazur <16736821+mzr@users.noreply.github.com>
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 915698f..816f858 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1918,6 +1918,8 @@
                              centDirSize, centDirOffset, len(self._comment))
         self.fp.write(endrec)
         self.fp.write(self._comment)
+        if self.mode == "a":
+            self.fp.truncate()
         self.fp.flush()
 
     def _fpclose(self, fp):