Skip to content

Commit

Permalink
Removing task now removes saved indexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
grigoryvp committed Mar 2, 2012
1 parent 878bdcc commit 5d4413d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
VALUES (:guid, :name, :src, :dst)"""
SQL_TASK_LIST = """SELECT * FROM task"""
SQL_TASK_DEL_BY_NAME = """DELETE FROM task WHERE name = :name"""
SQL_TASK_GUID_BY_NAME = """SELECT guid FROM task WHERE name = :name"""
SQL_INDEX_LAST_DEL = """DELETE FROM index_last WHERE guid = :guid"""

class Settings( object ) :

Expand Down Expand Up @@ -67,9 +69,19 @@ def taskAdd( self, i_sName, i_sSrc, i_sDst ) :
@classmethod
def taskDelByName( self, i_sName ) :
with sqlite3.connect( FILE_CFG ) as oConn :
oRet = oConn.execute( SQL_TASK_DEL_BY_NAME, { 'name' : i_sName } )
self.notifyIfNeeded()
return 1 == oRet.rowcount
try :
mArgs = { 'name' : i_sName }
oRow = oConn.execute( SQL_TASK_GUID_BY_NAME, mArgs ).fetchone()
if oRow is None :
return False
mArgs[ 'guid' ] = oRow[ 'guid' ]
oRet = oConn.execute( SQL_TASK_DEL_BY_NAME, mArgs )
if 0 == oRet.rowcount :
raise Exception( "Consistency error" )
oConn.execute( SQL_INDEX_LAST_DEL, mArgs )
return True
finally :
self.notifyIfNeeded()

@classmethod
def taskList( self ) :
Expand Down

0 comments on commit 5d4413d

Please sign in to comment.