Check if directory is in media directory, not just media cache, to avoid false negative if cache is unpopulated
This commit is contained in:
parent
8ad4ca586e
commit
66087de5f0
@ -1731,19 +1731,29 @@ class FileSwitchManager(object):
|
|||||||
return directory
|
return directory
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def isDirectoryInList(self, directoryToFind, folderList):
|
||||||
|
if directoryToFind and folderList:
|
||||||
|
normedDirectoryToFind = os.path.normcase(os.path.normpath(directoryToFind))
|
||||||
|
for listedFolder in folderList:
|
||||||
|
normedListedFolder = os.path.normcase(os.path.normpath(listedFolder))
|
||||||
|
if normedDirectoryToFind.startswith(normedListedFolder):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def notifyUserIfFileNotInMediaDirectory(self, filenameToFind, path):
|
def notifyUserIfFileNotInMediaDirectory(self, filenameToFind, path):
|
||||||
directoryToFind = os.path.dirname(path)
|
directoryToFind = os.path.dirname(path)
|
||||||
if directoryToFind in self.mediaDirectoriesNotFound:
|
if directoryToFind in self.mediaDirectoriesNotFound:
|
||||||
return
|
return
|
||||||
if self.mediaDirectories and self.mediaFilesCache is not None:
|
if self.mediaDirectories is not None and self.mediaFilesCache is not None:
|
||||||
if self.mediaFilesCache:
|
if directoryToFind in self.mediaFilesCache:
|
||||||
|
return
|
||||||
|
for directory in self.mediaFilesCache:
|
||||||
|
files = self.mediaFilesCache[directory]
|
||||||
|
if filenameToFind in files:
|
||||||
|
return
|
||||||
if directoryToFind in self.mediaFilesCache:
|
if directoryToFind in self.mediaFilesCache:
|
||||||
return
|
return
|
||||||
for directory in self.mediaFilesCache:
|
if self.isDirectoryInList(directoryToFind, self.mediaDirectories):
|
||||||
files = self.mediaFilesCache[directory]
|
return
|
||||||
if filenameToFind in files:
|
|
||||||
return
|
|
||||||
if directoryToFind in self.mediaFilesCache:
|
|
||||||
return
|
|
||||||
self._client.ui.showErrorMessage(getMessage("added-file-not-in-media-directory-error").format(directoryToFind))
|
self._client.ui.showErrorMessage(getMessage("added-file-not-in-media-directory-error").format(directoryToFind))
|
||||||
self.mediaDirectoriesNotFound.append(directoryToFind)
|
self.mediaDirectoriesNotFound.append(directoryToFind)
|
||||||
Loading…
x
Reference in New Issue
Block a user