[dak/master 16/50] process-upload: make sure we clean up after ourself
Signed-off-by: Frank Lichtenheld <djpig@debian.org>
---
dak/process_upload.py | 8 ++++++++
daklib/queue.py | 22 +++++++++++++++-------
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/dak/process_upload.py b/dak/process_upload.py
index e3a19ac..a78d146 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 2b86d4c..bb62aae 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)
###########################################################################
--
1.6.3.3
Reply to: