[projects/pld-ftp-admin] pfa-mvpkg, pfa-testmvpkg: check the files a move needs before removing anything

arekm arekm at pld-linux.org
Sat Oct 31 14:46:00 CET 2026


commit 1d276b8fba2e1900fd7d7fec30f2426e9a130611
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Oct 31 11:06:12 2026 +0100

    pfa-mvpkg, pfa-testmvpkg: check the files a move needs before removing anything
    
    pfa-mvpkg removes the other versions of a package before it moves the
    new one, and nothing checked that the files were there. A missing rpm
    stopped the move with a traceback after the destination had lost its
    version; only a destination with signature checks noticed it earlier.
    A build the destination already listed for an arch had its files
    removed from the source as already present, even when the destination
    did not have them, and archiving an old version did the same with the
    archive.
    
    pfa-mvpkg now refuses the move, before it removes anything, when one of
    these files is missing, and pfa-testmvpkg reports it.

 modules/ftptree.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
---
diff --git a/modules/ftptree.py b/modules/ftptree.py
index 97b079d..ae4ab82 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -241,6 +241,20 @@ class Pkg(BasePkg):
                         files.append(self.tree.basedir + '/' + arch + '/RPMS/' + nvr)
         return files
 
+    def missingfiles(self, dsttree):
+        """
+        Files a move to dsttree needs but are missing: those of the package, and for an arch dsttree
+        already has for this nvr, the same files there, as move() removes them here as already present
+        """
+        present = dsttree[self.nvr].files if dsttree.has_key(self.nvr) else {}
+        missing = []
+        for arch, rpmfiles in self.files.items():
+            trees = [self.tree, dsttree] if arch in present else [self.tree]
+            for rpmfile in rpmfiles:
+                path = f"/{arch}/{'debuginfo' if self.is_debuginfo(rpmfile) else 'RPMS'}/{rpmfile}"
+                missing += [tree.basedir + path for tree in trees if not os.path.exists(tree.basedir + path)]
+        return missing
+
     def move(self, dsttree, test = False):
         if dsttree.has_key(self.nvr):
             movedany = False
@@ -323,6 +337,7 @@ class FtpTree(BaseFtpTree):
         self.__checkbuild(self.marked4moving)
         self.__checkarchs(dsttree, self.marked4moving)
         self.__checkduplicates(dsttree, self.marked4moving)
+        self.__checkfiles(dsttree, archivetree, self.marked4moving)
 
         self.__checksigns(dsttree, self.marked4moving, test = True)
         self.__checkforobsoletes(dsttree, self.marked4moving, test = True)
@@ -347,6 +362,9 @@ class FtpTree(BaseFtpTree):
         self.__checkduplicates(dsttree, self.marked4moving)
         bailoutonerror()
 
+        self.__checkfiles(dsttree, archivetree, self.marked4moving)
+        bailoutonerror()
+
         self.__checksigns(dsttree, self.marked4moving)
         bailoutonerror()
 
@@ -495,6 +513,20 @@ class FtpTree(BaseFtpTree):
             else:
                 first[pkg.name] = pkg.nvr
 
+    def __checkfiles(self, dsttree, archivetree, marked):
+        """
+        Checks the files the move needs are there, before it removes anything: those of marked pkgs,
+        and those of the other versions in dsttree that go to archivetree
+        """
+        for pkg in marked:
+            for path in pkg.missingfiles(dsttree):
+                pkg.error(f'missing {path}')
+            # the versions __rmotherfromdst() archives, when movepkgs() calls it
+            if archivetree is not None and not dsttree.treename.count("archive"):
+                for nvr in self.__find_other_pkgs(pkg, dsttree):
+                    for path in Pkg(nvr, dsttree).missingfiles(archivetree):
+                        pkg.error(f'missing {path}, so {nvr} cannot be archived')
+
     def __rmolderfromsrc(self, test = False):
         for pkg in self.marked4moving:
             olderpkgnames = self.__find_older_pkgs(pkg)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/1d276b8fba2e1900fd7d7fec30f2426e9a130611



More information about the pld-cvs-commit mailing list