Remove special status of current directory and only look for files in media directories (for consistency)

This commit is contained in:
Et0h 2016-05-28 16:27:02 +01:00
parent 0dc2a23df0
commit cbc8203007
4 changed files with 8 additions and 44 deletions

View File

@ -1575,7 +1575,6 @@ class FileSwitchManager(object):
self.mediaFilesCache = {} self.mediaFilesCache = {}
self.filenameWatchlist = [] self.filenameWatchlist = []
self.currentDirectory = None self.currentDirectory = None
self.lastCheckedCurrentDirectory = None
self.mediaDirectories = None self.mediaDirectories = None
self.lock = threading.Lock() self.lock = threading.Lock()
self.folderSearchEnabled = True self.folderSearchEnabled = True
@ -1591,7 +1590,6 @@ class FileSwitchManager(object):
def setCurrentDirectory(self, curDir): def setCurrentDirectory(self, curDir):
self.currentDirectory = curDir self.currentDirectory = curDir
self.updateInfo()
def setMediaDirectories(self, mediaDirs): def setMediaDirectories(self, mediaDirs):
self.mediaDirectories = mediaDirs self.mediaDirectories = mediaDirs
@ -1610,15 +1608,6 @@ class FileSwitchManager(object):
self.filenameWatchlist = unfoundFilenames self.filenameWatchlist = unfoundFilenames
def _updateInfoThread(self): def _updateInfoThread(self):
if not self.folderSearchEnabled:
if self.lastCheckedCurrentDirecotry <> self.currentDirectory:
self.lastCheckedCurrentDirectory = self.currentDirectory
self.newInfo = True
elif self.areWatchedFilenamesInCurrentDir():
self.newInfo = True
return
with self.lock: with self.lock:
try: try:
self.currentlyUpdating = True self.currentlyUpdating = True
@ -1633,36 +1622,24 @@ class FileSwitchManager(object):
if time.time() - startTime > constants.FOLDER_SEARCH_TIMEOUT: if time.time() - startTime > constants.FOLDER_SEARCH_TIMEOUT:
self.disabledDir = directory self.disabledDir = directory
self.folderSearchEnabled = False self.folderSearchEnabled = False
if self.areWatchedFilenamesInCurrentDir():
self.newInfo = True
return return
if self.mediaFilesCache <> newMediaFilesCache or self.lastCheckedCurrentDirectory <> self.currentDirectory: if self.mediaFilesCache <> newMediaFilesCache:
self.mediaFilesCache = newMediaFilesCache self.mediaFilesCache = newMediaFilesCache
self.lastCheckedCurrentDirectory = self.currentDirectory
self.newInfo = True
elif self.areWatchedFilenamesInCurrentDir():
self.newInfo = True self.newInfo = True
finally: finally:
self.currentlyUpdating = False self.currentlyUpdating = False
def infoUpdated(self): def infoUpdated(self):
if self.areWatchedFilenamesInCache() or self.areWatchedFilenamesInCurrentDir(): if self.areWatchedFilenamesInCache():
self._client.fileSwitchFoundFiles() self._client.fileSwitchFoundFiles()
def findFilepath(self, filename, highPriority=False): def findFilepath(self, filename, highPriority=False):
if filename is None: if filename is None:
return return
if self.currentDirectory is not None:
candidatePath = os.path.join(self.currentDirectory,filename)
if os.path.isfile(candidatePath):
return candidatePath
if self.mediaFilesCache is not None: if self.mediaFilesCache is not None:
for directory in self.mediaFilesCache: for directory in self.mediaFilesCache:
if self.currentDirectory and self.currentDirectory == directory:
continue
files = self.mediaFilesCache[directory] files = self.mediaFilesCache[directory]
if len(files) > 0 and filename in files: if len(files) > 0 and filename in files:
filepath = os.path.join(directory, filename) filepath = os.path.join(directory, filename)
@ -1683,25 +1660,12 @@ class FileSwitchManager(object):
return None return None
return None return None
def areWatchedFilenamesInCurrentDir(self):
if self.filenameWatchlist is not None and self.currentDirectory is not None:
for filename in self.filenameWatchlist:
potentialPath = os.path.join(self.currentDirectory,filename)
if os.path.isfile(potentialPath):
return True
def areWatchedFilenamesInCache(self): def areWatchedFilenamesInCache(self):
if self.filenameWatchlist is not None: if self.filenameWatchlist is not None:
for filename in self.filenameWatchlist: for filename in self.filenameWatchlist:
if self.isFilenameInCache(filename): if self.isFilenameInCache(filename):
return True return True
def isFilenameInCurrentDir(self, filename):
if filename is not None and self.currentDirectory is not None:
potentialPath = os.path.join(self.currentDirectory,filename)
if os.path.isfile(potentialPath):
return True
def isFilenameInCache(self, filename): def isFilenameInCache(self, filename):
if filename is not None and self.mediaFilesCache is not None: if filename is not None and self.mediaFilesCache is not None:
for directory in self.mediaFilesCache: for directory in self.mediaFilesCache:

View File

@ -136,7 +136,7 @@ de = {
"invalid-seek-value" : u"Ungültige Zeitangabe", "invalid-seek-value" : u"Ungültige Zeitangabe",
"invalid-offset-value" : u"Ungültiger Offset-Wert", "invalid-offset-value" : u"Ungültiger Offset-Wert",
"switch-file-not-found-error" : u"Konnte nicht zur Datei '{0}' wechseln. Syncplay sucht im Ordner der aktuellen Datei und angegebenen Medien-Verzeichnissen.", # File not found, folder it was not found in "switch-file-not-found-error" : u"Konnte nicht zur Datei '{0}' wechseln. Syncplay looks in the specified media directories.", # File not found, folder it was not found in # TODO: Re-translate "Syncplay sucht im Ordner der aktuellen Datei und angegebenen Medien-Verzeichnissen." to reference to checking in "current media directory"
"folder-search-timeout-error" : u"Die Suche nach Mediendateien in '{}' wurde abgebrochen weil sie zu lange gedauert hat. Dies tritt auf, wenn ein zu durchsuchender Medienordner zu viele Unterordner hat. Syncplay wird bis zum Neustart nur noch das Verzeichnis der aktuellen Datei durchsuchen.", #Folder "folder-search-timeout-error" : u"Die Suche nach Mediendateien in '{}' wurde abgebrochen weil sie zu lange gedauert hat. Dies tritt auf, wenn ein zu durchsuchender Medienordner zu viele Unterordner hat. Syncplay wird bis zum Neustart nur noch das Verzeichnis der aktuellen Datei durchsuchen.", #Folder
"failed-to-load-server-list-error" : u"Konnte die Liste der öffentlichen Server nicht laden. Bitte besuche http://www.syncplay.pl/ [Englisch] mit deinem Browser.", "failed-to-load-server-list-error" : u"Konnte die Liste der öffentlichen Server nicht laden. Bitte besuche http://www.syncplay.pl/ [Englisch] mit deinem Browser.",
@ -375,7 +375,7 @@ de = {
# Playlists TODO: Translate all this to German # Playlists TODO: Translate all this to German
"playlist-selection-changed-notification" : u"{} changed the playlist selection", # Username "playlist-selection-changed-notification" : u"{} changed the playlist selection", # Username
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username "playlist-contents-changed-notification" : u"{} updated the playlist", # Username
"cannot-find-file-for-playlist-switch-error" : u"Could not find file {} for playlist switch!", # Filename "cannot-find-file-for-playlist-switch-error" : u"Could not find file {} in media directories for playlist switch!", # Filename
"cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename "cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename
"cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename
"sharedplaylistenabled-label" : u"Enable shared playlists", "sharedplaylistenabled-label" : u"Enable shared playlists",

View File

@ -136,7 +136,7 @@ en = {
"invalid-seek-value" : u"Invalid seek value", "invalid-seek-value" : u"Invalid seek value",
"invalid-offset-value" : u"Invalid offset value", "invalid-offset-value" : u"Invalid offset value",
"switch-file-not-found-error" : u"Could not switch to file '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found "switch-file-not-found-error" : u"Could not switch to file '{0}'. Syncplay looks specified media directories.", # File not found
"folder-search-timeout-error" : u"The search for media in '{}' was aborted as it took too long. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. Until Syncplay is restarted only the directory of the currently open file will be checked.", #Folder "folder-search-timeout-error" : u"The search for media in '{}' was aborted as it took too long. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. Until Syncplay is restarted only the directory of the currently open file will be checked.", #Folder
"failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.", "failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.",
@ -376,7 +376,7 @@ en = {
# Playlists # Playlists
"playlist-selection-changed-notification" : u"{} changed the playlist selection", # Username "playlist-selection-changed-notification" : u"{} changed the playlist selection", # Username
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username "playlist-contents-changed-notification" : u"{} updated the playlist", # Username
"cannot-find-file-for-playlist-switch-error" : u"Could not find file {} for playlist switch!", # Filename "cannot-find-file-for-playlist-switch-error" : u"Could not find file {} in media directories for playlist switch!", # Filename
"cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename "cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename
"cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename
"sharedplaylistenabled-label" : u"Enable shared playlists", "sharedplaylistenabled-label" : u"Enable shared playlists",

View File

@ -136,7 +136,7 @@ ru = {
"invalid-seek-value" : u"Некорректное значение для перемотки", "invalid-seek-value" : u"Некорректное значение для перемотки",
"invalid-offset-value" : u"Некорректное смещение", "invalid-offset-value" : u"Некорректное смещение",
"switch-file-not-found-error" : u"Невозможно переключиться на файл '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found # TODO: Translate last part into Russian "switch-file-not-found-error" : u"Невозможно переключиться на файл '{0}'. Syncplay looks in the folder specified media directories.", # File not found # TODO: Translate last part into Russian
"folder-search-timeout-error" : u"The search for media in '{}' was aborted as it took too long. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. Until Syncplay is restarted only the directory of the currently open file will be checked.", #Folder # TODO: Translate into Russian "folder-search-timeout-error" : u"The search for media in '{}' was aborted as it took too long. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. Until Syncplay is restarted only the directory of the currently open file will be checked.", #Folder # TODO: Translate into Russian
"failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.", # TODO: Translate into Russian "failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.", # TODO: Translate into Russian
@ -375,7 +375,7 @@ ru = {
# Playlists TODO: Translate all this to Russian # Playlists TODO: Translate all this to Russian
"playlist-selection-changed-notification" : u"{} changed the playlist selection", # Username "playlist-selection-changed-notification" : u"{} changed the playlist selection", # Username
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username "playlist-contents-changed-notification" : u"{} updated the playlist", # Username
"cannot-find-file-for-playlist-switch-error" : u"Could not find file {} for playlist switch!", # Filename "cannot-find-file-for-playlist-switch-error" : u"Could not find file {} in media directories for playlist switch!", # Filename
"cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename "cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename
"cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename "cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename
"sharedplaylistenabled-label" : u"Enable shared playlists", "sharedplaylistenabled-label" : u"Enable shared playlists",