From b3dda02f0965b86b8593f989c9e4838fd91515ba Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sat, 25 Jan 2014 15:36:47 +0100 Subject: [PATCH] Make sure to close all handles on eject drive Signed-off-by: Sven Strickroth --- src/Git/GitStatus.cpp | 6 ++++++ src/Git/GitStatus.h | 3 ++- src/Git/gitindex.h | 13 +++++++++++++ src/TGitCache/GITStatusCache.cpp | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Git/GitStatus.cpp b/src/Git/GitStatus.cpp index ba18f9adc..48c5e2985 100644 --- a/src/Git/GitStatus.cpp +++ b/src/Git/GitStatus.cpp @@ -1025,3 +1025,9 @@ bool GitStatus::ReleasePath(const CString &gitdir) return true; } +bool GitStatus::ReleasePathsRecursively(const CString &rootpath) +{ + g_IndexFileMap.SafeClearRecursively(rootpath); + return true; +} + diff --git a/src/Git/GitStatus.h b/src/Git/GitStatus.h index d6e989722..2dd7a8472 100644 --- a/src/Git/GitStatus.h +++ b/src/Git/GitStatus.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// 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 @@ -103,6 +103,7 @@ public: static __int64 GetIndexFileTime(const CString &gitdir); static bool IsExistIndexLockFile(const CString &gitdir); static bool ReleasePath(const CString &gitdir); + static bool ReleasePathsRecursively(const CString &rootpath); public: GitStatus(); diff --git a/src/Git/gitindex.h b/src/Git/gitindex.h index 84fa6c5d5..f5def1652 100644 --- a/src/Git/gitindex.h +++ b/src/Git/gitindex.h @@ -95,6 +95,19 @@ public: return true; } + bool SafeClearRecursively(const CString &rootpath) + { + CString thePath = rootpath; + thePath.MakeLower(); + CAutoLocker lock(m_critIndexSec); + for (auto it = this->begin(); it != this->end(); ++it) + { + if ((*it).first.Find(thePath) == 0) + (*this)[(*it).first] = nullptr; + } + return true; + } + int Check(const CString &gitdir, bool *isChanged); int LoadIndex(const CString &gitdir); diff --git a/src/TGitCache/GITStatusCache.cpp b/src/TGitCache/GITStatusCache.cpp index 595973173..3c3aead04 100644 --- a/src/TGitCache/GITStatusCache.cpp +++ b/src/TGitCache/GITStatusCache.cpp @@ -589,6 +589,7 @@ void CGitStatusCache::CloseWatcherHandles(HDEVNOTIFY hdev) { CTGitPath path = watcher.CloseInfoMap(hdev); m_folderCrawler.BlockPath(path); + CGitStatusCache::Instance().m_GitStatus.ReleasePathsRecursively(path.GetWinPathString()); } void CGitStatusCache::CloseWatcherHandles(const CTGitPath& path) -- 2.11.4.GIT