fix assistant's use of lsof in crippled filesystem mode
This commit is contained in:
parent
a988b90826
commit
630f4531a7
2 changed files with 21 additions and 12 deletions
|
@ -240,8 +240,7 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
|
||||||
{- Files can Either be Right to be added now,
|
{- Files can Either be Right to be added now,
|
||||||
- or are unsafe, and must be Left for later.
|
- or are unsafe, and must be Left for later.
|
||||||
-
|
-
|
||||||
- Check by running lsof on the temp directory, which
|
- Check by running lsof on the repository.
|
||||||
- the KeySources are locked down in.
|
|
||||||
-}
|
-}
|
||||||
safeToAdd :: Maybe Seconds -> [Change] -> [Change] -> Assistant [Either Change Change]
|
safeToAdd :: Maybe Seconds -> [Change] -> [Change] -> Assistant [Either Change Change]
|
||||||
safeToAdd _ [] [] = return []
|
safeToAdd _ [] [] = return []
|
||||||
|
@ -249,12 +248,12 @@ safeToAdd delayadd pending inprocess = do
|
||||||
maybe noop (liftIO . threadDelaySeconds) delayadd
|
maybe noop (liftIO . threadDelaySeconds) delayadd
|
||||||
liftAnnex $ do
|
liftAnnex $ do
|
||||||
keysources <- mapM Command.Add.lockDown (map changeFile pending)
|
keysources <- mapM Command.Add.lockDown (map changeFile pending)
|
||||||
let inprocess' = catMaybes $
|
let inprocess' = inprocess ++ catMaybes (map mkinprocess $ zip pending keysources)
|
||||||
map mkinprocess (zip pending keysources)
|
|
||||||
tmpdir <- fromRepo gitAnnexTmpDir
|
|
||||||
openfiles <- S.fromList . map fst3 . filter openwrite <$>
|
openfiles <- S.fromList . map fst3 . filter openwrite <$>
|
||||||
liftIO (Lsof.queryDir tmpdir)
|
findopenfiles (map keySource inprocess')
|
||||||
let checked = map (check openfiles) $ inprocess ++ inprocess'
|
liftIO $ print openfiles
|
||||||
|
let checked = map (check openfiles) inprocess'
|
||||||
|
liftIO $ print checked
|
||||||
|
|
||||||
{- If new events are received when files are closed,
|
{- If new events are received when files are closed,
|
||||||
- there's no need to retry any changes that cannot
|
- there's no need to retry any changes that cannot
|
||||||
|
@ -290,3 +289,18 @@ safeToAdd delayadd pending inprocess = do
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
|
|
||||||
allRight = return . map Right
|
allRight = return . map Right
|
||||||
|
|
||||||
|
{- Normally the KeySources are locked down inside the temp directory,
|
||||||
|
- so can just lsof that, which is quite efficient.
|
||||||
|
-
|
||||||
|
- In crippled filesystem mode, there is no lock down, so must run lsof
|
||||||
|
- on each individual file.
|
||||||
|
-}
|
||||||
|
findopenfiles keysources = ifM crippledFileSystem
|
||||||
|
( liftIO $ do
|
||||||
|
let segments = segmentXargs $ map keyFilename keysources
|
||||||
|
concat <$> forM segments (\fs -> Lsof.query $ "--" : fs)
|
||||||
|
, do
|
||||||
|
tmpdir <- fromRepo gitAnnexTmpDir
|
||||||
|
liftIO $ Lsof.queryDir tmpdir
|
||||||
|
)
|
||||||
|
|
|
@ -20,11 +20,6 @@ is probably needed for at least older Android devices that have SD cards.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
* In crippled filesystem mode, files are not hardlinked to a quarantine
|
|
||||||
directory, so the assistant's use of lsof on that directory won't work.
|
|
||||||
Instead, it should run lsof on the whole repository, and ignore other
|
|
||||||
stuff. (Not really much slower even in a large repo, according to
|
|
||||||
benchmarks.)
|
|
||||||
* rsync backend creates hard links
|
* rsync backend creates hard links
|
||||||
* migrate creates hard links between old and new keys
|
* migrate creates hard links between old and new keys
|
||||||
* avoid all symlink creation in crippled filesystem + direct mode
|
* avoid all symlink creation in crippled filesystem + direct mode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue