Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[videoinfoscanner] modified fasthash method to incorporate the exclud…

…e from scan expressions and return a md5 hash
  • Loading branch information...
commit 4c5b7357f6c20dab1ae5977caaa69efc767f0efa 1 parent 5fb87c1
@mkortstiege mkortstiege authored
Showing with 28 additions and 14 deletions.
  1. +21 −11 xbmc/video/VideoInfoScanner.cpp
  2. +7 −3 xbmc/video/VideoInfoScanner.h
32 xbmc/video/VideoInfoScanner.cpp
@@ -263,7 +263,7 @@ namespace VIDEO
m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(str), info->Name().c_str()));
- CStdString fastHash = GetFastHash(strDirectory);
+ CStdString fastHash = GetFastHash(strDirectory, regexps);
if (m_database.GetPathHash(strDirectory, dbHash) && !fastHash.empty() && fastHash == dbHash)
{ // fast hashes match - no need to process anything
CLog::Log(LOGDEBUG, "VideoInfoScanner: Skipping dir '%s' due to no change (fasthash)", CURL::GetRedacted(strDirectory).c_str());
@@ -297,7 +297,7 @@ namespace VIDEO
// update the hash to a fast hash if needed
- if (CanFastHash(items) && !fastHash.empty())
+ if (CanFastHash(items, regexps) && !fastHash.empty())
hash = fastHash;
@@ -1664,18 +1664,23 @@ namespace VIDEO
return count;
- bool CVideoInfoScanner::CanFastHash(const CFileItemList &items) const
+ bool CVideoInfoScanner::CanFastHash(const CFileItemList &items, const CStdStringArray &excludes) const
- // TODO: Probably should account for excluded folders here (eg samples), though that then
- // introduces possible problems if the user then changes the exclude regexps and
- // expects excluded folders that are inside a fast-hashed folder to then be picked
- // up. The chances that the user has a folder which contains only excluded folders
- // where some of those folders should be scanned recursively is pretty small.
- return items.GetFolderCount() == 0;
+ for (int i = 0; i < items.Size(); ++i)
+ {
+ if (items[i]->m_bIsFolder && !CUtil::ExcludeFileOrFolder(items[i]->GetPath(), excludes))
+ return false;
+ }
+ return true;
- CStdString CVideoInfoScanner::GetFastHash(const CStdString &directory) const
+ CStdString CVideoInfoScanner::GetFastHash(const CStdString &directory, const CStdStringArray &excludes) const
+ XBMC::XBMC_MD5 md5state;
+ if (excludes.size())
+ md5state.append(StringUtils::JoinString(excludes, "|"));
struct __stat64 buffer;
if (XFILE::CFile::Stat(directory, &buffer) == 0)
@@ -1683,7 +1688,12 @@ namespace VIDEO
if (!time)
time = buffer.st_ctime;
if (time)
- return StringUtils::Format("fast%"PRId64, time);
+ {
+ md5state.append((unsigned char *)&time, sizeof(time));
+ CStdString pathHash;
+ md5state.getDigest(pathHash);
+ return pathHash;
+ }
return "";
10 xbmc/video/VideoInfoScanner.h
@@ -185,19 +185,23 @@ namespace VIDEO
Performs a stat() on the directory, and uses modified time to create a "fast"
hash of the folder. If no modified time is available, the create time is used,
and if neither are available, an empty hash is returned.
+ In case exclude from scan expressions are present, the string array will be appended
+ to the md5 hash to ensure we're doing a re-scan whenever the user modifies those.
\param directory folder to hash
- \return the hash of the folder of the form "fast<datetime>"
+ \param excludes string array of exclude expressions
+ \return the md5 hash of the folder"
- CStdString GetFastHash(const CStdString &directory) const;
+ CStdString GetFastHash(const CStdString &directory, const CStdStringArray &excludes) const;
/*! \brief Decide whether a folder listing could use the "fast" hash
Fast hashing can be done whenever the folder contains no scannable subfolders, as the
fast hash technique uses modified time to determine when folder content changes, which
is generally not propogated up the directory tree.
\param items the directory listing
+ \param excludes string array of exclude expressions
\return true if this directory listing can be fast hashed, false otherwise
- bool CanFastHash(const CFileItemList &items) const;
+ bool CanFastHash(const CFileItemList &items, const CStdStringArray &excludes) const;
/*! \brief Process a series folder, filling in episode details and adding them to the database.
TODO: Ideally we would return INFO_HAVE_ALREADY if we don't have to update any episodes
Please sign in to comment.
Something went wrong with that request. Please try again.