Improve ssh socket cleanup code to skip over the cruft that NFS sometimes puts in a directory when a file is being deleted.
This commit is contained in:
parent
ce5f407b4c
commit
1a8ba7eab4
3 changed files with 64 additions and 2 deletions
13
Annex/Ssh.hs
13
Annex/Ssh.hs
|
@ -136,11 +136,20 @@ prepSocket socketfile = do
|
|||
liftIO $ createDirectoryIfMissing True $ parentDir socketfile
|
||||
lockFileCached $ socket2lock socketfile
|
||||
|
||||
{- Find ssh socket files.
|
||||
-
|
||||
- The check that the lock file exists makes only socket files
|
||||
- that were set up by prepSocket be found. On some NFS systems,
|
||||
- a deleted socket file may linger for a while under another filename;
|
||||
- and this check makes such files be skipped since the corresponding lock
|
||||
- file won't exist.
|
||||
-}
|
||||
enumSocketFiles :: Annex [FilePath]
|
||||
enumSocketFiles = go =<< sshCacheDir
|
||||
enumSocketFiles = liftIO . go =<< sshCacheDir
|
||||
where
|
||||
go Nothing = return []
|
||||
go (Just dir) = liftIO $ filter (not . isLock)
|
||||
go (Just dir) = filterM (doesFileExist . socket2lock)
|
||||
=<< filter (not . isLock)
|
||||
<$> catchDefaultIO [] (dirContents dir)
|
||||
|
||||
{- Stop any unused ssh connection caching processes. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue