From 138f3821d1b070640360c20970a5d9262db40f72 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 30 Dec 2014 02:17:50 +0100 Subject: [PATCH] Cleanup files cache for directories we're going to re-scan Signed-off-by: Sven Strickroth --- src/TGitCache/CachedDirectory.cpp | 12 ++++++++++++ src/TGitCache/CachedDirectory.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/TGitCache/CachedDirectory.cpp b/src/TGitCache/CachedDirectory.cpp index 4c57a403b..a7ff82c8a 100644 --- a/src/TGitCache/CachedDirectory.cpp +++ b/src/TGitCache/CachedDirectory.cpp @@ -459,12 +459,22 @@ int CCachedDirectory::EnumFiles(const CTGitPath &path , bool IsFull) AutoLocker lock(m_critSec); // clear subdirectory status cache m_childDirectories.clear(); + // build new files status cache + m_entryCache_tmp.clear(); } m_mostImportantFileStatus = git_wc_status_none; pStatus->EnumDirStatus(sProjectRoot, sSubPath, &status, IsFull, false, true, GetStatusCallback,this); m_mostImportantFileStatus = GitStatus::GetMoreImportant(m_mostImportantFileStatus, status); + { + AutoLocker lock(m_critSec); + // use a tmp files status cache so that we can still use the old cached values + // for deciding whether we have to issue a shell notify + m_entryCache = m_entryCache_tmp; + m_entryCache_tmp.clear(); + } + // need to set/construct m_ownStatus (only unversioned and normal are valid values) m_ownStatus = git_wc_status_unversioned; m_ownStatus.SetKind(git_node_dir); @@ -553,6 +563,8 @@ CCachedDirectory::AddEntry(const CTGitPath& path, const git_wc_status2_t* pGitSt // TEMP(?): git status doesn't not have "entry" that contains node type, so manually set as file entry_it->second.SetKind(git_node_file); + childDir->m_entryCache_tmp[cachekey] = entry_it->second; + if(bNotified) { CGitStatusCache::Instance().UpdateShell(path); diff --git a/src/TGitCache/CachedDirectory.h b/src/TGitCache/CachedDirectory.h index 0afe1c57a..cf3a7ae40 100644 --- a/src/TGitCache/CachedDirectory.h +++ b/src/TGitCache/CachedDirectory.h @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // External Cache Copyright (C) 2005 - 2006, 2008, 2014 - TortoiseSVN -// Copyright (C) 2008-2012 - TortoiseGit +// Copyright (C) 2008-2012, 2014 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -82,6 +82,7 @@ private: // The cache of files and directories within this directory typedef std::map CacheEntryMap; CacheEntryMap m_entryCache; + CacheEntryMap m_entryCache_tmp; // used for updating m_entryCache and removing "removed" entries /// A vector if iterators to child directories - used to put-together recursive status typedef std::map ChildDirStatus; -- 2.11.4.GIT