Fix nullreference exception when adding new files before starting sparkleshare
This commit is contained in:
parent
f4c2a3e951
commit
6af7fdf1e8
|
@ -37,24 +37,31 @@ namespace SparkleLib {
|
|||
|
||||
public static class SparkleListenerFactory {
|
||||
|
||||
private static List<SparkleListenerBase> listeners;
|
||||
private static List<SparkleListenerBase> listeners = new List<SparkleListenerBase> ();
|
||||
|
||||
public static SparkleListenerBase CreateListener (string uri, string folder_identifier)
|
||||
public static SparkleListenerBase CreateListener (string folder_name, string folder_identifier)
|
||||
{
|
||||
if (listeners == null)
|
||||
listeners = new List<SparkleListenerBase> ();
|
||||
string announce_uri = SparkleConfig.DefaultConfig.GetAnnouncementUrlForFolder (folder_name);
|
||||
|
||||
if (announce_uri == null) {
|
||||
// This is SparkleShare's centralized notification service.
|
||||
// Don't worry, we only use this server as a backup if you
|
||||
// don't have your own. All data needed to connect is hashed and
|
||||
// we don't store any personal information ever
|
||||
|
||||
announce_uri = "irc://204.62.14.135/";
|
||||
}
|
||||
|
||||
Uri listen_on = new Uri(uri);
|
||||
|
||||
foreach (SparkleListenerBase listener in listeners) {
|
||||
if (listener.Server.Equals (uri)) {
|
||||
SparkleHelpers.DebugInfo ("ListenerFactory", "Refered to existing listener for " + uri);
|
||||
if (listener.Server.Equals (announce_uri)) {
|
||||
SparkleHelpers.DebugInfo ("ListenerFactory", "Refered to existing listener for " + announce_uri);
|
||||
listener.AlsoListenTo (folder_identifier);
|
||||
return (SparkleListenerBase) listener;
|
||||
}
|
||||
}
|
||||
|
||||
SparkleHelpers.DebugInfo ("ListenerFactory", "Issued new listener for " + uri);
|
||||
Uri listen_on = new Uri (announce_uri);
|
||||
|
||||
switch (listen_on.Scheme) {
|
||||
case "tcp":
|
||||
listeners.Add (new SparkleListenerTcp (listen_on, folder_identifier));
|
||||
|
@ -65,6 +72,7 @@ namespace SparkleLib {
|
|||
break;
|
||||
}
|
||||
|
||||
SparkleHelpers.DebugInfo ("ListenerFactory", "Issued new listener for " + announce_uri);
|
||||
return (SparkleListenerIrc) listeners [listeners.Count - 1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ namespace SparkleLib {
|
|||
CreateInitialChangeSet ();
|
||||
|
||||
CreateWatcher ();
|
||||
CreateListener ();
|
||||
|
||||
this.local_timer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||
CheckForChanges ();
|
||||
|
@ -114,9 +115,6 @@ namespace SparkleLib {
|
|||
}
|
||||
};
|
||||
|
||||
this.remote_timer.Start ();
|
||||
this.local_timer.Start ();
|
||||
|
||||
// Sync up everything that changed
|
||||
// since we've been offline
|
||||
if (AnyDifferences) {
|
||||
|
@ -127,6 +125,9 @@ namespace SparkleLib {
|
|||
SyncUpBase ();
|
||||
EnableWatching ();
|
||||
}
|
||||
|
||||
this.remote_timer.Start ();
|
||||
this.local_timer.Start ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -217,9 +218,9 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
public void CreateListener (string uri, string folder_name)
|
||||
public void CreateListener ()
|
||||
{
|
||||
this.listener = SparkleListenerFactory.CreateListener(uri, this.Identifier);
|
||||
this.listener = SparkleListenerFactory.CreateListener (Name, Identifier);
|
||||
|
||||
// Stop polling when the connection to the irc channel is succesful
|
||||
this.listener.Connected += delegate {
|
||||
|
|
|
@ -542,21 +542,6 @@ namespace SparkleShare {
|
|||
else
|
||||
repo = new SparkleRepoGit (folder_path, SparkleBackend.DefaultBackend);
|
||||
|
||||
|
||||
string announce_uri = SparkleConfig.DefaultConfig.GetAnnouncementUrlForFolder (folder_name);
|
||||
if (announce_uri == null) {
|
||||
string announcements = SparkleConfig.DefaultConfig.GetAnnouncementsForFolder (folder_name);
|
||||
if (announcements == null)
|
||||
// This is SparkleShare's centralized notification service.
|
||||
// Don't worry, we only use this server as a backup if you
|
||||
// don't have your own. All data needed to connect is hashed and
|
||||
// we don't store any personal information ever
|
||||
announcements = "204.62.14.135";
|
||||
|
||||
announce_uri = String.Format("irc://{0}/", announcements);
|
||||
}
|
||||
repo.CreateListener(announce_uri, folder_name);
|
||||
|
||||
repo.NewChangeSet += delegate (SparkleChangeSet change_set, string repository_path) {
|
||||
string message = FormatMessage (change_set);
|
||||
|
||||
|
|
Loading…
Reference in a new issue