devtools: Fix cleanup of temporary database (closes #1908656)

The stored database path for clean up was not absolute.

We now make the db-name absolute at database manade initialization. before storing the name for cleanup.

authorPierre-Yves David <pierre-yves.david@logilab.fr>
changeset6f6253e44bdd
branchstable
phasepublic
hiddenno
parent revision#c709f6c457ff Drop privileges properly (closes #1910561)
child revision#a832677c0aa6 [views/navigation] use the proper icons instead of ascii art (closes #1624943)
files modified by this revision
devtools/__init__.py
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1315315745 -7200
# Tue Sep 06 15:29:05 2011 +0200
# Branch stable
# Node ID 6f6253e44bdd2a24fe1be656412bd544266b3d17
# Parent c709f6c457ffd4811b603ac41c04c2d16f94cb3e
devtools: Fix cleanup of temporary database (closes #1908656)

The stored database path for clean up was not absolute.

We now make the ``db-name`` absolute at database manade initialization. before
storing the name for cleanup.

diff --git a/devtools/__init__.py b/devtools/__init__.py
@@ -670,12 +670,13 @@
1          super(SQLiteTestDataBaseHandler, self).__init__(*args, **kwargs)
2          # use a dedicated base for each process.
3          if 'global-db-name' not in self.system_source:
4              self.system_source['global-db-name'] = self.system_source['db-name']
5              process_db = self.system_source['db-name'] + str(os.getpid())
6 -            self.__TMPDB.add(process_db)
7              self.system_source['db-name'] = process_db
8 +        process_db = self.absolute_dbfile() # update db-name to absolute path
9 +        self.__TMPDB.add(process_db)
10 
11      @staticmethod
12      def _cleanup_database(dbfile):
13          try:
14              os.remove(dbfile)
@@ -692,11 +693,10 @@
15          dbfile = join(self._ensure_test_backup_db_dir(),
16                        self.config.sources()['system']['db-name'])
17          self.config.sources()['system']['db-name'] = dbfile
18          return dbfile
19 
20 -
21      def process_cache_entry(self, directory, dbname, db_id, entry):
22          return entry.get('sqlite')
23 
24      def _backup_database(self, db_id=DEFAULT_EMPTY_DB_ID):
25          # XXX remove database file if it exists ???