Skip to content

Commit

Permalink
fixed: Use exact matching for protocol in file+dir factories (fixes v…
Browse files Browse the repository at this point in the history
…fs.sftp addon issue garbear#37)

changed: Consistently prefer addon protocols over internal protocols
  • Loading branch information
arnova committed Aug 19, 2019
1 parent f879d0e commit 9e9d81c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
22 changes: 12 additions & 10 deletions xbmc/filesystem/DirectoryFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,21 @@ IDirectory* CDirectoryFactory::Create(const CURL& url)
return NULL;

CFileItem item(url.Get(), true);
IFileDirectory* pDir=CFileDirectoryFactory::Create(url, &item);
IFileDirectory* pDir = CFileDirectoryFactory::Create(url, &item);
if (pDir)
return pDir;

if (!url.GetProtocol().empty() && CServiceBroker::IsBinaryAddonCacheUp())
{
for (const auto& vfsAddon : CServiceBroker::GetVFSAddonCache().GetAddonInstances())
{
auto prots = StringUtils::Split(vfsAddon->GetProtocols(), "|");

if (vfsAddon->HasDirectories() && std::find(prots.begin(), prots.end(), url.GetProtocol()) != prots.end())
return new CVFSEntryIDirectoryWrapper(vfsAddon);
}
}

#ifdef TARGET_POSIX
if (url.GetProtocol().empty() || url.IsProtocol("file")) return new CPosixDirectory();
#elif defined(TARGET_WINDOWS)
Expand Down Expand Up @@ -161,15 +172,6 @@ IDirectory* CDirectoryFactory::Create(const CURL& url)
if (url.IsProtocol("pvr"))
return new CPVRDirectory();

if (!url.GetProtocol().empty() && CServiceBroker::IsBinaryAddonCacheUp())
{
for (const auto& vfsAddon : CServiceBroker::GetVFSAddonCache().GetAddonInstances())
{
if (vfsAddon->HasDirectories() && vfsAddon->GetProtocols().find(url.GetProtocol()) != std::string::npos)
return new CVFSEntryIDirectoryWrapper(vfsAddon);
}
}

CLog::Log(LOGWARNING, "%s - unsupported protocol(%s) in %s", __FUNCTION__, url.GetProtocol().c_str(), url.GetRedacted().c_str() );
return NULL;
}
Expand Down
8 changes: 4 additions & 4 deletions xbmc/filesystem/FileFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ IFile* CFileFactory::CreateLoader(const CURL& url)
if (!CWakeOnAccess::GetInstance().WakeUpHost(url))
return NULL;

std::string strProtocol = url.GetProtocol();
if (!strProtocol.empty() && CServiceBroker::IsBinaryAddonCacheUp())
if (!url.GetProtocol().empty() && CServiceBroker::IsBinaryAddonCacheUp())
{
StringUtils::ToLower(strProtocol);
for (const auto& vfsAddon : CServiceBroker::GetVFSAddonCache().GetAddonInstances())
{
if (vfsAddon->HasFiles() && vfsAddon->GetProtocols().find(strProtocol) != std::string::npos)
auto prots = StringUtils::Split(vfsAddon->GetProtocols(), "|");

if (vfsAddon->HasFiles() && std::find(prots.begin(), prots.end(), url.GetProtocol()) != prots.end())
return new CVFSEntryIFileWrapper(vfsAddon);
}
}
Expand Down

0 comments on commit 9e9d81c

Please sign in to comment.