From 854a55166c3a095a7128b0b30d90b94622e6ede5 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 2 Jan 2014 10:29:10 +0100 Subject: [PATCH] Fix for an Issue #588 --- lib/utils/api.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/utils/api.py b/lib/utils/api.py index 665827409..58cdb820c 100644 --- a/lib/utils/api.py +++ b/lib/utils/api.py @@ -104,6 +104,7 @@ class Database(object): class Task(object): def __init__(self, taskid): self.process = None + self.temporary_directory = False self.output_directory = None self.options = None self._original_options = None @@ -144,12 +145,23 @@ class Task(object): self.options = AttribDict(self._original_options) def set_output_directory(self): + if self.get_option("oDir"): + if os.path.isdir(self.get_option("oDir")): + self.output_directory = self.get_option("oDir") + else: + try: + os.makedirs(self.get_option("oDir")) + self.output_directory = self.get_option("oDir") + except OSError: + pass + if not self.output_directory or not os.path.isdir(self.output_directory): self.output_directory = tempfile.mkdtemp(prefix="sqlmapoutput-") + self.temporary_directory = True self.set_option("oDir", self.output_directory) def clean_filesystem(self): - if self.output_directory: + if self.output_directory and self.temporary_directory: shutil.rmtree(self.output_directory) def engine_start(self):