Fixed defect with deleting old logs not working with 0 rows
This commit is contained in:
parent
dca95f5780
commit
264c8ccbdc
1 changed files with 4 additions and 2 deletions
4
log.py
4
log.py
|
@ -139,9 +139,11 @@ class logsManager:
|
|||
|
||||
oldestLogQuery = f"SELECT TOP 1 {logTimeColumn} FROM {tableName} ORDER BY {logTimeColumn} ASC"
|
||||
cursor.execute(oldestLogQuery)
|
||||
|
||||
if cursor.rowcount > 0:
|
||||
oldestLogTime = cursor.fetchone()[0]
|
||||
|
||||
if oldestLogTime is not None and oldestLogTime < datetime.now() - timedelta(days=int(logRetentionDays)):
|
||||
if cursor.rowcount > 0 and oldestLogTime < datetime.now() - timedelta(days=int(logRetentionDays)):
|
||||
|
||||
deleteQuery = f"DELETE FROM {tableName} WHERE {logTimeColumn} < ?"
|
||||
cursor.execute(deleteQuery, datetime.now() - timedelta(days=int(logRetentionDays)))
|
||||
|
|
Loading…
Reference in a new issue