From: Frank Lichtenheld Date: Fri, 30 Oct 2009 22:06:29 +0000 (+0000) Subject: process-upload: make sure we clean up after ourself X-Git-Tag: debian-r/squeeze~914^2~21^2~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5fe430f729ce19c539932a43338ad0522f0723f6;p=dak.git process-upload: make sure we clean up after ourself Signed-off-by: Frank Lichtenheld --- diff --git a/dak/process_upload.py b/dak/process_upload.py index e3a19ac3..a78d146c 100755 --- a/dak/process_upload.py +++ b/dak/process_upload.py @@ -166,6 +166,7 @@ def usage (exit_code=0): def action(u): cnf = Config() + holding = Holding() # changes["distribution"] may not exist in corner cases # (e.g. unreadable changes files) @@ -233,6 +234,11 @@ def action(u): ############################################################################### +def cleanup(): + h = Holding() + if not Options["No-Action"]: + h.clean() + def process_it(changes_file): global Logger @@ -302,12 +308,14 @@ def process_it(changes_file): action(u) except (SystemExit, KeyboardInterrupt): + cleanup() raise except: print "ERROR" traceback.print_exc(file=sys.stderr) + cleanup() # Restore previous WD os.chdir(u.prevdir) diff --git a/daklib/queue.py b/daklib/queue.py index 2b86d4cc..bb62aaee 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -2006,15 +2006,21 @@ distribution.""" def remove(self, from_dir=None): """ Used (for instance) in p-u to remove the package from unchecked + + Also removes the package from holding area. """ if from_dir is None: - os.chdir(self.pkg.directory) - else: - os.chdir(from_dir) + from_dir = self.pkg.directory + h = Holding() for f in self.pkg.files.keys(): - os.unlink(f) - os.unlink(self.pkg.changes_file) + os.unlink(os.path.join(from_dir, f)) + if os.path.exists(os.path.join(h.holding_dir, f)): + os.unlink(os.path.join(h.holding_dir, f)) + + os.unlink(os.path.join(from_dir, self.pkg.changes_file)) + if os.path.exists(os.path.join(h.holding_dir, self.pkg.changes_file)): + os.unlink(os.path.join(h.holding_dir, self.pkg.changes_file)) ########################################################################### @@ -2022,9 +2028,11 @@ distribution.""" """ Move files to dest with certain perms/changesperms """ - utils.move(self.pkg.changes_file, dest, perms=changesperms) + h = Holding() + utils.move(os.path.join(h.holding_dir, self.pkg.changes_file), + dest, perms=changesperms) for f in self.pkg.files.keys(): - utils.move(f, dest, perms=perms) + utils.move(os.path.join(h.holding_dir, f), dest, perms=perms) ###########################################################################