git-annex/Utility
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
..
DirWatcher let's put type modules under the parent module, not in a Types directory 2013-03-10 22:24:13 -04:00
Gpg GnuPG options for symmetric encryption. 2013-03-11 09:48:38 -04:00
Applicative.hs pointlessness 2012-06-29 10:00:05 -04:00
Base64.hs tag xmpp pushes with jid 2013-03-06 16:29:19 -04:00
CoProcess.hs refactoring 2013-05-11 23:11:56 -04:00
CopyFile.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
Daemon.hs fix the day's Windows permissions damage 2013-05-14 20:15:14 -04:00
DataUnits.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
DBus.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
Directory.hs rename module 2013-05-12 19:19:28 -04:00
DirWatcher.hs assistant: Fix OSX bug that prevented committing changed files to a repository when in indirect mode. 2013-03-17 17:01:43 -04:00
DiskFree.hs tweak 2013-03-13 14:54:52 -04:00
Dot.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
Env.hs fix the day's windows permissions damage 2013-05-12 19:09:48 -04:00
Exception.hs reconnect XMPP when NetWatcher notices a change 2012-10-27 00:42:14 -04:00
ExternalSHA.hs configure: Better checking that sha commands output in the desired format. 2013-05-08 11:17:09 -04:00
FileMode.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
FileSystemEncoding.hs add decodeW8 2012-09-13 19:14:29 -04:00
Format.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
FreeDesktop.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
FSEvents.hs let's put type modules under the parent module, not in a Types directory 2013-03-10 22:24:13 -04:00
Gpg.hs fix the day's Windows permissions damage 2013-05-14 20:15:14 -04:00
HumanTime.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
InodeCache.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
INotify.hs whups, I didn't mean to commit this, it was in to more quickly test out of limit behavior 2013-04-24 11:52:24 -04:00
JSONStream.hs whitespace fixes 2012-12-13 00:45:27 -04:00
Kqueue.hs let's put type modules under the parent module, not in a Types directory 2013-03-10 22:24:13 -04:00
libdiskfree.c Makefile now builds using cabal, taking advantage of cabal's automatic detection of appropriate build flags. 2013-02-27 02:39:22 -04:00
libdiskfree.h Renamed diskfree.c to avoid OSX case insensativity bug. 2012-04-13 11:26:39 -04:00
libkqueue.c include sys/types.h 2013-04-24 10:39:52 -04:00
libkqueue.h fix prototype 2012-06-19 01:57:19 -04:00
libmounts.c cleanup 2012-07-19 21:20:38 -04:00
libmounts.h Got removable media mount detection working on Android. 2013-05-04 16:19:25 -04:00
LogFile.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Lsof.hs clean up from windows porting 2013-05-11 18:23:41 -04:00
Matcher.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
Metered.hs webapp: Progess bar fixes for many types of special remotes. 2013-03-28 17:04:37 -04:00
Misc.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
Monad.hs pasto 2012-11-02 12:48:52 -04:00
Mounts.hsc Got removable media mount detection working on Android. 2013-05-04 16:19:25 -04:00
Network.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
NotificationBroadcaster.hs webapp: Fix a race that sometimes caused alerts or other notifications to be missed if they occurred while a page was loading. 2013-03-27 14:56:20 -04:00
OSX.hs squelch warning 2012-11-26 16:29:05 -04:00
Parallel.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
PartialPrelude.hs rename readMaybe to readish 2012-01-23 17:00:10 -04:00
Path.hs fix the day's Windows permissions damage 2013-05-14 20:15:14 -04:00
Percentage.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
Process.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
QuickCheck.hs Stop depending on testpack. 2013-02-27 23:23:41 -04:00
Rsync.hs deal with Cygwin rsync paths issue 2013-05-14 13:24:15 -04:00
SafeCommand.hs webapp: Run ssh server probes in a way that will work when the login shell is a monstrosity that should have died 25 years ago, such as csh. 2013-03-29 13:09:30 -04:00
Shell.hs fix use of wrong shebang when android is installing git-annex-shell wrapper on server 2013-05-06 15:58:13 -04:00
SRV.hs Makefile now builds using cabal, taking advantage of cabal's automatic detection of appropriate build flags. 2013-02-27 02:39:22 -04:00
Tense.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
ThreadLock.hs reorg 2012-06-17 14:02:40 -04:00
ThreadScheduler.hs cleanup 2013-03-14 22:05:23 -04:00
TList.hs use DList for the transfer queue 2013-04-25 01:33:44 -04:00
Tmp.hs rename module 2013-05-12 19:19:28 -04:00
Touch.hsc finished where indentation changes 2012-12-13 00:24:19 -04:00
Url.hs fix permission damage (thanks, Windows) 2013-05-11 23:54:25 -04:00
UserInfo.hs fix the day's windows permissions damage 2013-05-12 19:09:48 -04:00
Verifiable.hs finished where indentation changes 2012-12-13 00:24:19 -04:00
WebApp.hs rename module 2013-05-12 19:19:28 -04:00
Yesod.hs don't need any of this on android 2013-04-15 19:32:45 -04:00