git-annex/Command
Joey Hess 345ee4f37c Switch to MonadCatchIO-transformers for better handling of state while catching exceptions.
As seen in this bug report, the lifted exception handling using the StateT
monad throws away state changes when an action throws an exception.
http://git-annex.branchable.com/bugs/git_annex_fork_bombs_on_gpg_file/
  .. Which can result in cached values being redundantly calculated, or other
     possibly worse bugs when the annex state gets out of sync with reality.

This switches from a StateT AnnexState to a ReaderT (MVar AnnexState).
All changes to the state go via the MVar. So when an Annex action is
running inside an exception handler, and it makes some changes, they
immediately go into affect in the MVar. If it then throws an exception
(or even crashes its thread!), the state changes are still in effect.

The MonadCatchIO-transformers change is actually only incidental.
I could have kept on using lifted-base for the exception handling.
However, I'd have needed to write a new instance of MonadBaseControl
for the new monad.. and I didn't write the old instance.. I begged Bas
and he kindly sent it to me. Happily, MonadCatchIO-transformers is
able to derive a MonadCatchIO instance for my monad.

This is a deep level change. It passes the test suite! What could it break?

Well.. The most likely breakage would be to code that runs an Annex action
in an exception handler, and *wants* state changes to be thrown away.
Perhaps the state changes leaves the state inconsistent, or wrong. Since
there are relatively few places in git-annex that catch exceptions in the
Annex monad, and the AnnexState is generally just used to cache calculated
data, this is unlikely to be a problem.

Oh yeah, this change also makes Assistant.Types.ThreadedMonad a bit
redundant. It's now entirely possible to run concurrent Annex actions in
different threads, all sharing access to the same state! The ThreadedMonad
just adds some extra work on top of that, with its own MVar, and avoids
such actions possibly stepping on one-another's toes. I have not gotten
rid of it, but might try that later. Being able to run concurrent Annex
actions would simplify parts of the Assistant code.
2013-05-19 14:16:36 -04:00
..
Add.hs Switch to MonadCatchIO-transformers for better handling of state while catching exceptions. 2013-05-19 14:16:36 -04:00
AddUnused.hs addurl: Bugfix: Did not properly add file in direct mode. 2013-04-11 13:35:52 -04:00
AddUrl.hs expose Control.Monad.join 2013-04-22 20:24:53 -04:00
Assistant.hs use setCurrentDirectory 2013-05-11 19:14:30 -04:00
Commit.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
ConfigList.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Copy.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Dead.hs webapp: Added UI to delete repositories. Closes: #689847 2013-03-31 16:38:05 -04:00
Describe.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Direct.hs direct, indirect: Refuse to do anything when the assistant or git-annex watch daemon is running. 2013-04-22 16:41:46 -04:00
Drop.hs drop --auto: Fix bug that prevented dropping files from untrusted repositories. 2013-04-01 15:20:42 -04:00
DropKey.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
DropUnused.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
EnableRemote.hs To enable an existing special remote, the new enableremote command must be used. The initremote command now is used only to create new special remotes. 2013-04-26 18:22:52 -04:00
Find.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Fix.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
FromKey.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Fsck.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Get.hs connect existing meters to the transfer log for downloads 2013-04-11 17:32:31 -04:00
Group.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Help.hs change section 2013-04-20 20:24:57 -04:00
Import.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
InAnnex.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Indirect.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Init.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
InitRemote.hs To enable an existing special remote, the new enableremote command must be used. The initremote command now is used only to create new special remotes. 2013-04-26 18:22:52 -04:00
Lock.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Log.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Map.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Merge.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Migrate.hs migrate: Detect if a file gets corrupted while it's being migrated. 2013-05-13 14:27:39 -04:00
Move.hs connect existing meters to the transfer log for downloads 2013-04-11 17:32:31 -04:00
PreCommit.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
RecvKey.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Reinject.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
ReKey.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
RmUrl.hs rmurl: New command, removes one of the recorded urls for a file. 2013-04-22 17:18:53 -04:00
Semitrust.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
SendKey.hs minor refactoring 2013-03-30 19:05:51 -04:00
Status.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Sync.hs sync: Commit in direct mode even if no changes were staged 2013-04-23 17:14:28 -04:00
Test.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
TransferInfo.hs webapp: Progess bar fixes for many types of special remotes. 2013-03-28 17:04:37 -04:00
TransferKey.hs connect existing meters to the transfer log for downloads 2013-04-11 17:32:31 -04:00
TransferKeys.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Trust.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Unannex.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Ungroup.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Uninit.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Unlock.hs Use lower case hash directories for storing files on crippled filesystems, same as is already done for bare repositories. 2013-04-04 15:46:33 -04:00
Untrust.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Unused.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Upgrade.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Version.hs include build flags in version info when not in a repo 2013-05-01 23:11:13 -04:00
Vicfg.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
Watch.hs webapp: New --listen= option allows running the webapp on one computer and connecting to it from another. 2013-04-08 15:04:35 -04:00
WebApp.hs use setCurrentDirectory 2013-05-11 19:14:30 -04:00
Whereis.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00
XMPPGit.hs add section metadata to all commands 2013-03-24 18:28:21 -04:00