From aa224b63f6305e84949ba00e82eed17c03939c21 Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 25 Jan 2015 22:21:59 +0000 Subject: [PATCH] Fix bug when there are file differences and a user has no file open --- syncplay/__init__.py | 2 +- syncplay/client.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/syncplay/__init__.py b/syncplay/__init__.py index dbe21b3..ddaf47c 100644 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,4 +1,4 @@ version = '1.3.0' milestone = 'Chami' -release_number = '2' +release_number = '3' projectURL = 'http://syncplay.pl/' diff --git a/syncplay/client.py b/syncplay/client.py index 8f32077..ff54eb4 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -659,8 +659,9 @@ class SyncplayClient(object): if not self._client._player: return osdMessage = None - if not self._userlist.areAllFilesInRoomSame(): - fileDifferencesMessage = getMessage("room-file-differences").format(self._userlist.getFileDifferencesForRoom()) + fileDifferencesForRoom = self._userlist.getFileDifferencesForRoom() + if not self._userlist.areAllFilesInRoomSame() and fileDifferencesForRoom is not None: + fileDifferencesMessage = getMessage("room-file-differences").format(fileDifferencesForRoom) if self._userlist.currentUser.canControl() and self._userlist.isReadinessSupported(): if self._userlist.areAllUsersInRoomReady(): osdMessage = u"{}{}{}".format(fileDifferencesMessage, self._client._player.osdMessageSeparator, getMessage("all-users-ready").format(self._userlist.readyUserCount())) @@ -789,10 +790,14 @@ class SyncplayUserlist(object): message += getMessage("playing-notification/room-addendum").format(room) self.ui.showMessage(message, hideFromOSD) if self.currentUser.file and not self.currentUser.isFileSame(file_) and self.currentUser.room == room: - message = getMessage("file-differences-notification").format(self.getFileDifferencesForUser(self.currentUser.file, file_)) - self.ui.showMessage(message, True) + fileDifferences = self.getFileDifferencesForUser(self.currentUser.file, file_) + if fileDifferences is not None: + message = getMessage("file-differences-notification").format(fileDifferences) + self.ui.showMessage(message, True) def getFileDifferencesForUser(self, currentUserFile, otherUserFile): + if not currentUserFile or not otherUserFile: + return None differences = [] differentName = not utils.sameFilename(currentUserFile['name'], otherUserFile['name']) differentSize = not utils.sameFilesize(currentUserFile['size'], otherUserFile['size']) @@ -803,12 +808,14 @@ class SyncplayUserlist(object): return ", ".join(differences) def getFileDifferencesForRoom(self): + if not self.currentUser.file: + return None differences = [] differentName = False differentSize = False differentDuration = False for otherUser in self._users.itervalues(): - if otherUser.room == self.currentUser.room: + if otherUser.room == self.currentUser.room and otherUser.file: if not utils.sameFilename(self.currentUser.file['name'], otherUser.file['name']): differentName = True if not utils.sameFilesize(self.currentUser.file['size'], otherUser.file['size']):