try to prevent a major TB
This commit is contained in:
parent
f521185aa8
commit
9a5e49ac1c
2 changed files with 20 additions and 17 deletions
|
@ -73,7 +73,7 @@ class Logger:
|
||||||
ji = jid
|
ji = jid
|
||||||
nick = ''
|
nick = ''
|
||||||
files = []
|
files = []
|
||||||
if kind == 'status': #we save time:jid:show:msg
|
if kind == 'status': # we save time:jid:show:msg
|
||||||
if not show:
|
if not show:
|
||||||
show = 'online'
|
show = 'online'
|
||||||
if common.gajim.config.get('log_notif_in_user_file'):
|
if common.gajim.config.get('log_notif_in_user_file'):
|
||||||
|
|
|
@ -733,12 +733,12 @@ timestamp, contact):
|
||||||
if is_transport:
|
if is_transport:
|
||||||
return
|
return
|
||||||
|
|
||||||
#How many lines to restore and when to time them out
|
# How many lines to restore and when to time them out
|
||||||
restore = gajim.config.get('restore_lines')
|
restore = gajim.config.get('restore_lines')
|
||||||
time_out = gajim.config.get('restore_timeout')
|
time_out = gajim.config.get('restore_timeout')
|
||||||
pos = 0 #position, while reading from history
|
pos = 0 # position, while reading from history
|
||||||
size = 0 #how many lines we alreay retreived
|
size = 0 # how many lines we alreay retreived
|
||||||
lines = [] #we'll need to reverse the lines from history
|
lines = [] # we'll need to reverse the lines from history
|
||||||
count = gajim.logger.get_no_of_lines(jid)
|
count = gajim.logger.get_no_of_lines(jid)
|
||||||
|
|
||||||
|
|
||||||
|
@ -750,22 +750,25 @@ timestamp, contact):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
while size <= restore:
|
while size <= restore:
|
||||||
if pos == count or size > restore - 1:
|
if pos == count or size > restore - 1:
|
||||||
#don't try to read beyond history, not read more than required
|
# don't try to read beyond history, not read more than required
|
||||||
break
|
break
|
||||||
|
|
||||||
nb, line = gajim.logger.read(jid, count - 1 - pos, count - pos)
|
nb, line = gajim.logger.read(jid, count - 1 - pos, count - pos)
|
||||||
pos = pos + 1
|
pos = pos + 1
|
||||||
|
|
||||||
if (now - float(line[0][0]))/60 >= time_out:
|
print line
|
||||||
#stop looking for messages if we found something too old
|
# line is [] if log file for jid is not a file (does not exist or dir)
|
||||||
break
|
if line != []:
|
||||||
|
if (now - float(line[0][0]))/60 >= time_out:
|
||||||
|
# stop looking for messages if we found something too old
|
||||||
|
break
|
||||||
|
|
||||||
if line[0][1] != 'sent' and line[0][1] != 'recv':
|
if line[0][1] != 'sent' and line[0][1] != 'recv':
|
||||||
# we don't want to display status lines, do we?
|
# we don't want to display status lines, do we?
|
||||||
continue
|
continue
|
||||||
|
|
||||||
lines.append(line[0])
|
lines.append(line[0])
|
||||||
size = size + 1
|
size = size + 1
|
||||||
|
|
||||||
lines.reverse()
|
lines.reverse()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue