@@ -398,36 +398,39 @@ def dbTableValues(self, tableValues):
398398 self ._write (tableValues , content_type = CONTENT_TYPE .DUMP_TABLE )
399399 return
400400
401- _ = re .sub (r"[^\w]" , "_" , normalizeUnicode (unsafeSQLIdentificatorNaming (db )))
402- if len (_ ) < len (db ) or IS_WIN and db .upper () in WINDOWS_RESERVED_NAMES :
403- _ = unicodeencode (re .sub (r"[^\w]" , "_" , unsafeSQLIdentificatorNaming (db )))
404- dumpDbPath = os .path .join (conf .dumpPath , "%s-%s" % (_ , hashlib .md5 (unicodeencode (db )).hexdigest ()[:8 ]))
405- warnFile = True
406- else :
407- dumpDbPath = os .path .join (conf .dumpPath , _ )
408-
409401 if conf .dumpFormat == DUMP_FORMAT .SQLITE :
410402 replication = Replication (os .path .join (conf .dumpPath , "%s.sqlite3" % unsafeSQLIdentificatorNaming (db )))
411403 elif conf .dumpFormat in (DUMP_FORMAT .CSV , DUMP_FORMAT .HTML ):
404+ dumpDbPath = os .path .join (conf .dumpPath , unsafeSQLIdentificatorNaming (db ))
405+
412406 if not os .path .isdir (dumpDbPath ):
413407 try :
414408 os .makedirs (dumpDbPath , 0755 )
415- except (OSError , IOError ), ex :
416- try :
417- tempDir = tempfile .mkdtemp (prefix = "sqlmapdb" )
418- except IOError , _ :
419- errMsg = "unable to write to the temporary directory ('%s'). " % _
420- errMsg += "Please make sure that your disk is not full and "
421- errMsg += "that you have sufficient write permissions to "
422- errMsg += "create temporary files and/or directories"
423- raise SqlmapSystemException (errMsg )
424-
425- warnMsg = "unable to create dump directory "
426- warnMsg += "'%s' (%s). " % (dumpDbPath , ex )
427- warnMsg += "Using temporary directory '%s' instead" % tempDir
428- logger .warn (warnMsg )
429-
430- dumpDbPath = tempDir
409+ except :
410+ warnFile = True
411+
412+ _ = unicodeencode (re .sub (r"[^\w]" , "_" , unsafeSQLIdentificatorNaming (db )))
413+ dumpDbPath = os .path .join (conf .dumpPath , "%s-%s" % (_ , hashlib .md5 (unicodeencode (db )).hexdigest ()[:8 ]))
414+
415+ if not os .path .isdir (dumpDbPath ):
416+ try :
417+ os .makedirs (dumpDbPath , 0755 )
418+ except Exception , ex :
419+ try :
420+ tempDir = tempfile .mkdtemp (prefix = "sqlmapdb" )
421+ except IOError , _ :
422+ errMsg = "unable to write to the temporary directory ('%s'). " % _
423+ errMsg += "Please make sure that your disk is not full and "
424+ errMsg += "that you have sufficient write permissions to "
425+ errMsg += "create temporary files and/or directories"
426+ raise SqlmapSystemException (errMsg )
427+
428+ warnMsg = "unable to create dump directory "
429+ warnMsg += "'%s' (%s). " % (dumpDbPath , getSafeExString (ex ))
430+ warnMsg += "Using temporary directory '%s' instead" % tempDir
431+ logger .warn (warnMsg )
432+
433+ dumpDbPath = tempDir
431434
432435 _ = re .sub (r"[^\w]" , "_" , normalizeUnicode (unsafeSQLIdentificatorNaming (table )))
433436 if len (_ ) < len (table ) or IS_WIN and table .upper () in WINDOWS_RESERVED_NAMES :
0 commit comments