Commit graph

441 commits

Author SHA1 Message Date
Joey Hess
4dbdc2b666 Assistant monad, stage 2.5
Converted several threads to run in the monad.

Added a lot of useful combinators for working with the monad.

Now the monad includes the name of the thread.

Some debugging messages are disabled pending converting other threads.
2012-10-29 02:21:04 -04:00
Joey Hess
4e765327ca Assistant monad, stage 1
This adds the Assistant monad, and an AssistantData structure.
So far, none of the assistant's threads run in the monad yet.
2012-10-29 00:15:43 -04:00
Joey Hess
64e1d7b579 send git-annex tag in initial presence
Will be used for finding other git-annex clients for pairing
2012-10-28 17:07:29 -04:00
Joey Hess
4ac2fd0a22 ensure that git-annex branch is pushed after a successful transfer
I now have this topology working:

   assistant ---> {bare repo, special remote} <--- assistant

And, I think, also this one:

        +----------- bare repo --------+
        v                              v
  assistant ---> special remote <--- assistant

While before with assistant <---> assistant connections, both sides got
location info updated after a transfer, in this topology, the bare repo
*might* get its location info updated, but the other assistant has no way to
know that it did. And a special remote doesn't record location info,
so transfers to it won't propigate out location log changes at all.

So, for these to work, after a transfer succeeds, the git-annex branch
needs to be pushed. This is done by recording a synthetic commit has
occurred, which lets the pusher handle pushing out the change (which will
include actually committing any still journalled changes to the git-annex
branch).

Of course, this means rather a lot more syncing action than happened
before. At least the pusher bundles together very close together pushes,
somewhat. Currently it just waits 2 seconds between each push.
2012-10-28 16:05:34 -04:00
Joey Hess
5406416234 add git-annex branch commit when assistant is syncing
Seems nothing else ensures the branch is committed anymore.
2012-10-28 15:33:21 -04:00
Joey Hess
531f1d1446 add XMPP nudge alert, displayed after making a cloud repository 2012-10-27 12:25:29 -04:00
Joey Hess
b72d04988f add an icon for The Cloud
I am befuddled that Twitter Bootstrap has no built-in Icon for The Cloud,
and also that Chromium's depiction of CLOUD (U+2601) has an uncanny
resemblance to PILE OF POO (U+1F4A9) when rendered small, and looks like a
looming Frankenstorm when rendered large, and not a sweet, sunny, nothing
can go wrong The Cloud.
<http://www.fileformat.info/info/unicode/char/2601/browsertest.htm>

So, I must resort to irony in my choice of icons.
2012-10-27 11:24:35 -04:00
Joey Hess
c71836269b (re)start XMPP when it's configured in the webapp 2012-10-27 00:50:14 -04:00
Joey Hess
2dc40ecbd1 reconnect XMPP when NetWatcher notices a change 2012-10-27 00:42:14 -04:00
Joey Hess
9fc8257392 xmpp reconnection
If it managed to run for 5 minutes, reconnect immediately. Otherwise,
wait 5 minutes before reconnecting.
2012-10-27 00:06:17 -04:00
Joey Hess
0c0ef99341 gnutls segfault fixed
Adjust build deps to ensure that only a fixed version of the library will
be used.

Also, removed the bound thread stuff, which I now think was (probably)
a red herring.
2012-10-26 23:07:30 -04:00
Joey Hess
d1e5f2d596 Merge branch 'master' into xmpp
Conflicts:
	Assistant/Threads/NetWatcher.hs
2012-10-26 19:42:24 -04:00
Joey Hess
8e4620a6c7 NetWatcher: When dbus connection is lost, try to reconnect.
MountWatcher can't do this, because it uses the session dbus,
and won't have access to the new DBUS_SESSION_BUS_ADDRESS if a new session
is started.

Bumped dbus library version, FD leak in it is fixed.
2012-10-26 19:38:27 -04:00
Joey Hess
6803667f00 store xmpp creds from form 2012-10-26 17:13:30 -04:00
Joey Hess
1d04dff4f0 split out xmpp utilities 2012-10-26 14:44:36 -04:00
Joey Hess
82b7e835e4 run xmpp test in bound thread 2012-10-26 14:39:22 -04:00
Joey Hess
07494cbb4b XMPP configuration form
Currently relies on SRV being set, or the JID's hostname being the server
hostname and the port being default. Future work: Allow manual
configuration of user name, hostname, and port.
2012-10-26 14:17:09 -04:00
Joey Hess
a11fb94c65 SRV record construction 2012-10-26 13:03:08 -04:00
Joey Hess
5544ca2fb8 build fix with pairing disabled 2012-10-26 12:56:19 -04:00
Joey Hess
8916ff1a6c hook up SRV lookups for XMPP 2012-10-26 12:55:29 -04:00
Joey Hess
0b1cf3a766 Merge branch 'master' into xmpp
Conflicts:
	Assistant/Threads/MountWatcher.hs
	Assistant/Threads/NetWatcher.hs
2012-10-26 00:10:41 -04:00
Joey Hess
ef7b53e784 improved dbus error handling
Now when the dbus connection is dropped, it'll fall back to polling.

I could make it try to reconnect, but there's a FD leak in the dbus
library, so not yet.
2012-10-26 00:02:03 -04:00
Joey Hess
7ee0ffaeb9 Use USER and HOME environment when set, and only fall back to getpwent, which doesn't work with LDAP or NIS. 2012-10-25 18:17:54 -04:00
Joey Hess
fe96b28b4d convert the assistant to use a bound thread for XMPP
This *may* solve the segfault I was seeing when the XMPP library called
startTLS. My hypothesis is as follows:

* TLS is documented
  (http://www.gnu.org/software/gnutls/manual/gnutls.html#Thread-safety)
  thread safe, but only when a single thread accesses it.
* forkIO threads are not bound to an OS thread, so it was possible for
  the threaded runtime to run part of the XMPP code on one thread, and
  then switch to another thread later.

So, forkOS, with its bound threads, should be used for the XMPP thread.
Since the crash doesn't happen reliably, I am not yet sure about this fix.

Note that I kept all the other threads in the assistant unbound, because
bound threads have significantly higher overhead.
2012-10-25 15:47:27 -04:00
Joey Hess
8c9c8e3110 only use one push attribute
When pushing to multiple UUIDs, combine them all into a single push
attribute.
2012-10-25 13:31:45 -04:00
Joey Hess
91c0c7b9ef switch from presence toggle hack to git-annex tag in presence extended content
Push notifications are actually working over XMPP now!
2012-10-25 13:04:43 -04:00
Joey Hess
52d380d7f0 add a separate field for the JID 2012-10-24 19:09:02 -04:00
Joey Hess
145202f21e flip availablility
Seems presence notifications are not sent to clients that have marked
themselves unavailable. (Testing with google talk.)

This is the death knell for the presence hack, because it has to stay
available, and even the toggle to unavailable and back could cause it to
miss a notification. Still, flipped it so it basically works, for now.
2012-10-24 17:23:21 -04:00
Joey Hess
422b426460 pull from one of the remotes in a push notification
Still need to do something about transfer queueing, however. This could be
a real can of worms.
2012-10-24 16:21:45 -04:00
Joey Hess
32497feb2a initial implementation of XMPP push notifier (untested)
Lacking error handling, reconnection, credentials configuration,
and doesn't actually do anything when it receives an incoming notification.

Other than that, it might work! :)
2012-10-24 15:42:02 -04:00
Joey Hess
ae8a3ab31e added push notifier thread, currently a no-op
Hooked up everything that needs to notify on pushes. Note that
syncNewRemote does not notify. This is probably ok, and I'd need to thread
more state through to make it do so.

This is only set up to support a single push notification method; I didn't
use a NotificationBroadcaster. Partly because I don't yet know what info
about pushes needs to be communicated, so my data types are only
preliminary.
2012-10-24 13:38:28 -04:00
Joey Hess
6b6ce30b42 use a newtype for better type safety 2012-10-24 13:15:31 -04:00
Joey Hess
95f17ed0de webapp: Switched to using the same multicast IP address that avahi uses. 2012-10-22 15:50:30 -04:00
Joey Hess
12efabf070 webapp: Allow dashes in ssh key comments when pairing. 2012-10-22 11:18:19 -04:00
Joey Hess
bcaf320ed8 push out config changes 2012-10-21 15:50:49 -04:00
Joey Hess
452e6819d0 !! removal 2012-10-21 00:51:42 -04:00
Joey Hess
c7c2015435 add ConfigMonitor thread
Monitors git-annex branch for changes, which are noticed by the Merger
thread whenever the branch ref is changed (either due to an incoming push,
or a local change), and refreshes cached config values for modified config
files.

Rate limited to run no more often than once per minute. This is important
because frequent git-annex branch changes happen when files are being
added, or transferred, etc.

A primary use case is that, when preferred content changes are made,
and get pushed to remotes, the remotes start honoring those settings.
Other use cases include propigating repository description and trust
changes to remotes, and learning when a remote has added a new special
remote, so the webapp can present the GUI to enable that special remote
locally.

Also added a uuid.log cache. All other config files already had caches.
2012-10-20 16:43:35 -04:00
Joey Hess
813b28aa49 removed 3 partial !! and got a much nicer implementation
Yay, monadic Either!
2012-10-20 16:21:39 -04:00
Joey Hess
14b376d440 Merge branch 'safesemaphore'
Conflicts:
	debian/changelog
	git-annex.cabal
2012-10-20 12:44:25 -04:00
Joey Hess
73c28d2ca7 nasty race workaround 2012-10-19 16:59:18 -04:00
Joey Hess
f4c3a45da0 check preferred content when a file is moved or created
This can result in the file being dropped, or being downloaded, or even
being dropped from some other repo.

It's even possible to create a file in a directory where content is not
wanted, which will make the assistant immediately send it elsewhere, and
then drop it.
2012-10-19 14:22:13 -04:00
Joey Hess
9c89924c05 check and drop after uploads 2012-10-18 16:05:43 -04:00
Joey Hess
ee9e0702a2 check and drop unwanted content from remotes after receiving a transfer 2012-10-18 15:37:57 -04:00
Joey Hess
dea125e1b7 split 2012-10-18 15:22:28 -04:00
Joey Hess
f7f34d2072 drop unwanted content in the transfer scan
This was complicated quite a bit by needing to check numcopies. I optimised
that, so it only looks up numcopies once per file, no matter how many
remotes it checks to drop from. Although it did just occur to me that
it might be better to first check if it wants to drop content, and only
then check numcopies..
2012-10-18 15:07:11 -04:00
Joey Hess
dbe8de40ab minor transfer scanner code reworking
Also a small optimisation using a Set
2012-10-18 13:42:17 -04:00
Nicolas Pouillard
03ba7d6a87 One more #ifdef WITH_S3 2012-10-18 12:43:24 -04:00
Nicolas Pouillard
6b0a6cd226 import S3 only when enabled 2012-10-18 12:42:57 -04:00
Joey Hess
362e18e3fd allow renaming git remotes in the edit form 2012-10-14 17:18:01 -04:00
Joey Hess
08e1efb278 make repo description optional 2012-10-14 16:32:55 -04:00