Changeset 70 in tracdarcs


Ignore:
Timestamp:
12/08/07 12:08:10 (5 years ago)
Author:
lele@…
Hash name:
20071208110810-7a6fb-608bfccc78b5fffe31be99be386319608a7fa0a5
Message:

Remove the ugly hack, properly catch the exception
Sometime the sqlite runtime raise a strange exception on commit here, most
probably related to a concurrent update of the database. Since we are
trying to store the cache for the textual representation, absorb the error
and keep going: reasonably that same value has been stored shortly before...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tracdarcs/repository.py

    r69 r70  
    293293        # save the file content in the cache 
    294294 
    295         # UGLY HACK: the following line is required otherwise 
    296         # db.commit() (pysqlite-2.3.2,winxp) throws 
    297         # OperationalError: 'SQL logic error or missing database' 
    298         #self.__db.cnx.cnx.isolation_level = None 
    299         # END UGLY HACK 
    300  
    301295        c = self.__db.cursor() 
    302296        c.execute( 'INSERT INTO darcs_cache(node_id,rev,content) ' 
    303297                'VALUES (%s,%s,%s)', 
    304298                (self.__node_id,self.rev,buffer(data)) ) 
    305         self.__db.commit() 
     299        try: 
     300            self.__db.commit() 
     301        except Exception, e: 
     302            # Sometimes db.commit() (sqllite) throws an 
     303            # OperationalError: 'SQL logic error or missing database' 
     304            # Since this is just a cache, we simply notify and keep 
     305            # going. 
     306            self.__log.warning("Error writing cache: %s", e) 
    306307        return StringIO.StringIO( data ) 
    307308 
Note: See TracChangeset for help on using the changeset viewer.