diff options
author | 2012-06-20 20:05:40 -0400 | |
---|---|---|
committer | 2012-06-20 20:05:40 -0400 | |
commit | 75dba7f7bc50b75e08ee49cb4b758a375ef70d68 (patch) | |
tree | d436b5251eb9d5410081770e995f1f864a5d4511 | |
parent | 33b914bcf1f277aecccb4194e296f17f4708e434 (diff) |
belt and suspenders check
It's possible for there to be multiple queued changes all adding the same
file, and for those changes to be reordered. Maybe. This check will guard
against that ending up adding the wrong version of the file last.
-rw-r--r-- | Assistant/Committer.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Assistant/Committer.hs b/Assistant/Committer.hs index 46fee1b74..63df8cafc 100644 --- a/Assistant/Committer.hs +++ b/Assistant/Committer.hs @@ -118,7 +118,7 @@ handleAdds st changechan cs = returnWhen (null pendingadds) $ do add :: Change -> IO (Maybe Change) add change@(PendingAddChange { keySource = ks }) = do - r <- catchMaybeIO $ runThreadState st $ do + r <- catchMaybeIO $ sanitycheck ks $ runThreadState st $ do showStart "add" $ keyFilename ks handle (finishedChange change) (keyFilename ks) =<< Command.Add.ingest ks @@ -140,6 +140,16 @@ handleAdds st changechan cs = returnWhen (null pendingadds) $ do showEndOk return $ Just change + {- Check that the keysource's keyFilename still exists, + - and is still a hard link to its contentLocation, + - before ingesting it. -} + sanitycheck keysource a = do + fs <- getSymbolicLinkStatus $ keyFilename keysource + ks <- getSymbolicLinkStatus $ contentLocation keysource + if deviceID ks == deviceID fs && fileID ks == fileID fs + then a + else return Nothing + {- PendingAddChanges can Either be Right to be added now, - or are unsafe, and must be Left for later. - |