From ca9ec0627fb439d7ec671b244bcb2eb79305bd5d Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sat, 25 Jan 2014 17:41:49 +0100 Subject: [PATCH] Release handles also on DBT_DEVTYP_VOLUME This is needed to release handles e.g. on TrueCrypt unmount. Based on TortoiseSVN revision #16403. Signed-off-by: Sven Strickroth --- src/TGitCache/GITStatusCache.cpp | 2 +- src/TGitCache/TGITCache.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/TGitCache/GITStatusCache.cpp b/src/TGitCache/GITStatusCache.cpp index 45cb6a1d7..72110b874 100644 --- a/src/TGitCache/GITStatusCache.cpp +++ b/src/TGitCache/GITStatusCache.cpp @@ -597,5 +597,5 @@ void CGitStatusCache::CloseWatcherHandles(const CTGitPath& path) { watcher.CloseHandlesForPath(path); m_folderCrawler.ReleasePathForUpdate(path); - CGitStatusCache::Instance().m_GitStatus.ReleasePath(path.GetWinPathString()); + CGitStatusCache::Instance().m_GitStatus.ReleasePathsRecursively(path.GetWinPathString()); } diff --git a/src/TGitCache/TGITCache.cpp b/src/TGitCache/TGITCache.cpp index 4fd2d6177..11dfe2add 100644 --- a/src/TGitCache/TGITCache.cpp +++ b/src/TGitCache/TGITCache.cpp @@ -374,6 +374,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) CAutoWriteLock writeLock(CGitStatusCache::Instance().GetGuard()); CGitStatusCache::Instance().CloseWatcherHandles(phandle->dbch_handle); } + else if (phdr->dbch_devicetype == DBT_DEVTYP_VOLUME) + { + DEV_BROADCAST_VOLUME * pVolume = (DEV_BROADCAST_VOLUME*)lParam; + CAutoWriteLock writeLock(CGitStatusCache::Instance().GetGuard()); + for (BYTE i = 0; i < 26; ++i) + { + if (pVolume->dbcv_unitmask & (1 << i)) + { + TCHAR driveletter = 'A' + i; + CString drive = CString(driveletter); + drive += L":\\"; + CGitStatusCache::Instance().CloseWatcherHandles(CTGitPath(drive)); + } + } + } else { CAutoWriteLock writeLock(CGitStatusCache::Instance().GetGuard()); -- 2.11.4.GIT