unsent files fix

This commit is contained in:
ingvar1995 2017-03-04 22:15:42 +03:00
parent 0cfb8efefa
commit 019165aeac
3 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import contact
from messages import *
import os
class Friend(contact.Contact):
@ -37,6 +38,15 @@ class Friend(contact.Contact):
def clear_unsent_files(self):
self._corr = list(filter(lambda x: type(x) is not UnsentFile, self._corr))
def remove_invalid_unsent_files(self):
def is_valid(message):
if type(message) is not UnsentFile:
return True
if message.get_data()[1] is not None:
return True
return os.path.exists(message.get_data()[0])
self._corr = list(filter(is_valid, self._corr))
def delete_one_unsent_file(self, time):
self._corr = list(filter(lambda x: not (type(x) is UnsentFile and x.get_data()[2] == time), self._corr))

View File

@ -9,7 +9,7 @@ PAGE_SIZE = 42
TIMEOUT = 11
SAVE_MESSAGES = 150
SAVE_MESSAGES = 250
MESSAGE_OWNER = {
'ME': 0,

View File

@ -219,6 +219,7 @@ class Profile(basecontact.BaseContact, Singleton):
except:
pass
friend = self._contacts[value]
friend.remove_invalid_unsent_files()
if self._active_friend != value:
self._screen.messageEdit.setPlainText(friend.curr_text)
self._active_friend = value
@ -329,6 +330,7 @@ class Profile(basecontact.BaseContact, Singleton):
def send_files(self, friend_number):
friend = self.get_friend_by_number(friend_number)
friend.remove_invalid_unsent_files()
files = friend.get_unsent_files()
try:
for fl in files: