Part of lp.archivepublisher.diskpool View In Hierarchy
This class is designed to solve a very specific problem encountered in the publisher. Namely that should the publisher crash during the process of publishing a file to the pool, an empty or incomplete file would be present in the pool. Its mere presence would fool the publisher into believing it had already downloaded that file to the pool, resulting in failures in the apt-ftparchive stage.
By performing a rename() when the file is guaranteed to have been fully written to disk (after the fd.close()) we can be sure that if the filename is present in the pool, it is definitely complete.