aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Morten Kvarving <spiff@kodi.tv>2024-02-11 00:59:50 +0100
committerArne Morten Kvarving <spiff@kodi.tv>2024-05-05 21:42:50 +0200
commit94facd42ad002375667e4c6f0787fac7869437ec (patch)
treeabe53b8f375c991aefb20bb9335c77ba24d7fa80
parent67e9eba384d830fca76ef59b4d3067ca26c16c62 (diff)
downloadxbmc-94facd42ad002375667e4c6f0787fac7869437ec.tar.xz
move CFileItem::IsStreamedFileSystem to NetworkFileItemClassify
-rw-r--r--xbmc/FileItem.cpp8
-rw-r--r--xbmc/FileItem.h1
-rw-r--r--xbmc/network/NetworkFileItemClassify.cpp8
-rw-r--r--xbmc/network/NetworkFileItemClassify.h2
-rw-r--r--xbmc/network/test/TestNetworkFileItemClassify.cpp79
-rw-r--r--xbmc/video/VideoThumbLoader.cpp3
6 files changed, 91 insertions, 10 deletions
diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp
index 9744094416..03115ac8ef 100644
--- a/xbmc/FileItem.cpp
+++ b/xbmc/FileItem.cpp
@@ -967,14 +967,6 @@ bool CFileItem::IsPicture() const
return false;
}
-bool CFileItem::IsStreamedFilesystem() const
-{
- if (!m_strDynPath.empty())
- return URIUtils::IsStreamedFilesystem(m_strDynPath);
-
- return URIUtils::IsStreamedFilesystem(m_strPath);
-}
-
bool CFileItem::IsFileFolder(EFileFolderType types) const
{
EFileFolderType always_type = EFILEFOLDER_TYPE_ALWAYS;
diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h
index bf160b5070..99791f5238 100644
--- a/xbmc/FileItem.h
+++ b/xbmc/FileItem.h
@@ -172,7 +172,6 @@ public:
bool IsDeleted() const;
bool IsGame() const;
- bool IsStreamedFilesystem() const;
bool IsPlayList() const;
bool IsSmartPlayList() const;
bool IsLibraryFolder() const;
diff --git a/xbmc/network/NetworkFileItemClassify.cpp b/xbmc/network/NetworkFileItemClassify.cpp
index b73a0a45c9..c806d07b56 100644
--- a/xbmc/network/NetworkFileItemClassify.cpp
+++ b/xbmc/network/NetworkFileItemClassify.cpp
@@ -25,4 +25,12 @@ bool IsInternetStream(const CFileItem& item, const bool bStrictCheck /* = false
return URIUtils::IsInternetStream(item.GetPath(), bStrictCheck);
}
+bool IsStreamedFilesystem(const CFileItem& item)
+{
+ if (!item.GetDynPath().empty())
+ return URIUtils::IsStreamedFilesystem(item.GetDynPath());
+
+ return URIUtils::IsStreamedFilesystem(item.GetPath());
+}
+
} // namespace KODI::NETWORK
diff --git a/xbmc/network/NetworkFileItemClassify.h b/xbmc/network/NetworkFileItemClassify.h
index 22d34c1702..8f8b1d2444 100644
--- a/xbmc/network/NetworkFileItemClassify.h
+++ b/xbmc/network/NetworkFileItemClassify.h
@@ -16,4 +16,6 @@ namespace KODI::NETWORK
//! \brief Check whether an item is a an internet stream.
bool IsInternetStream(const CFileItem& item, const bool bStrictCheck = false);
+//! \brief Check whether an item is on a streamed filesystem.
+bool IsStreamedFilesystem(const CFileItem& item);
} // namespace KODI::NETWORK
diff --git a/xbmc/network/test/TestNetworkFileItemClassify.cpp b/xbmc/network/test/TestNetworkFileItemClassify.cpp
index 335b8340fc..0d195c887d 100644
--- a/xbmc/network/test/TestNetworkFileItemClassify.cpp
+++ b/xbmc/network/test/TestNetworkFileItemClassify.cpp
@@ -17,6 +17,21 @@
using namespace KODI;
+namespace
+{
+
+struct SimpleDefinition
+{
+ SimpleDefinition(const std::string& path, bool folder, bool res) : item(path, folder), result(res)
+ {
+ }
+
+ CFileItem item;
+ bool result;
+};
+
+} // namespace
+
struct InternetStreamDefinition
{
InternetStreamDefinition(const std::string& path, bool folder, bool strict, bool res)
@@ -175,3 +190,67 @@ TEST(TestNetworkWorkFileItemClassify, InternetStreamStacks)
EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), true));
EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true));
}
+
+class StreamedFilesystemTest : public testing::WithParamInterface<SimpleDefinition>,
+ public testing::Test
+{
+};
+
+TEST_P(StreamedFilesystemTest, IsStreamedFilesystem)
+{
+ EXPECT_EQ(NETWORK::IsStreamedFilesystem(GetParam().item), GetParam().result);
+}
+
+const auto streamedfs_tests = std::array{
+ SimpleDefinition{"/home/user/test.disc", false, false},
+ SimpleDefinition{"/home/user/test.disc", true, false},
+ SimpleDefinition{"http://some.where/foo", false, true},
+ SimpleDefinition{"http://some.where/foo", true, true},
+ SimpleDefinition{"https://some.where/foo", false, true},
+ SimpleDefinition{"https://some.where/foo", true, true},
+ SimpleDefinition{"ftp://some.where/foo", false, true},
+ SimpleDefinition{"ftp://some.where/foo", true, true},
+ SimpleDefinition{"sftp://some.where/foo", false, true},
+ SimpleDefinition{"sftp://some.where/foo", true, true},
+ SimpleDefinition{"ssh://some.where/foo", false, true},
+ SimpleDefinition{"ssh://some.where/foo", true, true},
+ SimpleDefinition{"ssh://some.where/foo", true, true},
+};
+
+INSTANTIATE_TEST_SUITE_P(TestNetworkFileItemClassify,
+ StreamedFilesystemTest,
+ testing::ValuesIn(streamedfs_tests));
+
+TEST(TestNetworkWorkFileItemClassify, StreamedFilesystemStacks)
+{
+ std::string stackPath;
+ EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath(
+ {"/home/foo/somthing.avi", "/home/bar/else.mkv"}, stackPath));
+ EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false)));
+ EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true)));
+
+ EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath(
+ {"https://home/foo/somthing.avi", "https://home/bar/else.mkv"}, stackPath));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false)));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true)));
+
+ EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath(
+ {"shout://home/foo/somthing.avi", "shout://home/bar/else.mkv"}, stackPath));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false)));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true)));
+
+ EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath(
+ {"ftp://home/foo/somthing.avi", "ftp://home/bar/else.mkv"}, stackPath));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false)));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true)));
+
+ EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath(
+ {"ftp://home/foo/somthing.avi", "/home/bar/else.mkv"}, stackPath));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false)));
+ EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true)));
+
+ EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath(
+ {"/home/foo/somthing.avi", "ftp://home/bar/else.mkv"}, stackPath));
+ EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false)));
+ EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true)));
+}
diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp
index 3522043a21..cc14f55f2f 100644
--- a/xbmc/video/VideoThumbLoader.cpp
+++ b/xbmc/video/VideoThumbLoader.cpp
@@ -22,6 +22,7 @@
#include "guilib/StereoscopicsManager.h"
#include "music/MusicDatabase.h"
#include "music/tags/MusicInfoTag.h"
+#include "network/NetworkFileItemClassify.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingUtils.h"
#include "settings/Settings.h"
@@ -524,7 +525,7 @@ std::string CVideoThumbLoader::GetLocalArt(const CFileItem &item, const std::str
settings ? settings->GetInt(CSettings::SETTING_FILECACHE_BUFFERMODE) == CACHE_BUFFER_MODE_ALL
: false;
- if (item.m_bIsFolder && (item.IsStreamedFilesystem() || cacheAll))
+ if (item.m_bIsFolder && (NETWORK::IsStreamedFilesystem(item) || cacheAll))
{
CFileItemList items; // Dummy list
CDirectory::GetDirectory(item.GetPath(), items, "", DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_READ_CACHE | DIR_FLAG_NO_FILE_INFO);