don't watch for addition of ~/SparkleShare subfolders
This commit is contained in:
parent
999c9f3ca2
commit
1bbf352028
|
@ -247,6 +247,7 @@ namespace SparkleLib {
|
||||||
server_type = NotificationServerType.Central;
|
server_type = NotificationServerType.Central;
|
||||||
else
|
else
|
||||||
server_type = NotificationServerType.Own;
|
server_type = NotificationServerType.Own;
|
||||||
|
|
||||||
this.listener = SparkleListenerFactory.CreateIrcListener (Domain, Identifier, server_type);
|
this.listener = SparkleListenerFactory.CreateIrcListener (Domain, Identifier, server_type);
|
||||||
|
|
||||||
// Stop polling when the connection to the irc channel is succesful
|
// Stop polling when the connection to the irc channel is succesful
|
||||||
|
@ -287,6 +288,8 @@ namespace SparkleLib {
|
||||||
// Start listening
|
// Start listening
|
||||||
if (!this.listener.IsConnected && !this.listener.IsConnecting)
|
if (!this.listener.IsConnected && !this.listener.IsConnecting)
|
||||||
this.listener.Connect ();
|
this.listener.Connect ();
|
||||||
|
else
|
||||||
|
this.is_polling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,11 @@ namespace SparkleShare {
|
||||||
if (File.Exists (old_global_config_file_path)) {
|
if (File.Exists (old_global_config_file_path)) {
|
||||||
MigrateConfig ();
|
MigrateConfig ();
|
||||||
FirstRun = false;
|
FirstRun = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
FirstRun = true;
|
FirstRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
FirstRun = false;
|
FirstRun = false;
|
||||||
AddKey ();
|
AddKey ();
|
||||||
|
@ -142,16 +144,12 @@ namespace SparkleShare {
|
||||||
FolderSizeChanged (FolderSize);
|
FolderSizeChanged (FolderSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Only support removing because 1. adding causes crashes and 2. Backend will be determined in
|
|
||||||
// the Intro and added to a table with the repo type, so we wont' know what type will be added
|
|
||||||
|
|
||||||
// Add the repository when a create event occurs
|
|
||||||
watcher.Created += delegate (object o, FileSystemEventArgs args) {
|
watcher.Created += delegate (object o, FileSystemEventArgs args) {
|
||||||
|
|
||||||
// Handle invitations when the user saves an
|
// Handle invitations when the user saves an
|
||||||
// invitation into the SparkleShare folder
|
// invitation into the SparkleShare folder
|
||||||
if (args.Name.EndsWith (".sparkle") && !FirstRun) {
|
if (args.Name.EndsWith (".sparkle") && !FirstRun) {
|
||||||
|
|
||||||
XmlDocument xml_doc = new XmlDocument ();
|
XmlDocument xml_doc = new XmlDocument ();
|
||||||
xml_doc.Load (args.Name);
|
xml_doc.Load (args.Name);
|
||||||
|
|
||||||
|
@ -162,16 +160,6 @@ namespace SparkleShare {
|
||||||
// FIXME: this is broken :\
|
// FIXME: this is broken :\
|
||||||
if (OnInvitation != null)
|
if (OnInvitation != null)
|
||||||
OnInvitation (server, folder, token);
|
OnInvitation (server, folder, token);
|
||||||
} else if (SparkleRepoBase.IsRepo (args.FullPath)) {
|
|
||||||
AddRepository (args.FullPath);
|
|
||||||
|
|
||||||
if (FolderListChanged != null)
|
|
||||||
FolderListChanged ();
|
|
||||||
|
|
||||||
FolderSize = GetFolderSize ();
|
|
||||||
|
|
||||||
if (FolderSizeChanged != null)
|
|
||||||
FolderSizeChanged (FolderSize);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -228,6 +216,7 @@ namespace SparkleShare {
|
||||||
if (response.StatusCode == HttpStatusCode.OK) {
|
if (response.StatusCode == HttpStatusCode.OK) {
|
||||||
response.Close ();
|
response.Close ();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
response.Close ();
|
response.Close ();
|
||||||
return false;
|
return false;
|
||||||
|
@ -405,14 +394,12 @@ namespace SparkleShare {
|
||||||
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", "<b>Yesterday</b>");
|
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->", "<b>Yesterday</b>");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (activity_day.DateTime.Year != DateTime.Now.Year) {
|
if (activity_day.DateTime.Year != DateTime.Now.Year) {
|
||||||
|
|
||||||
// TRANSLATORS: This is the date in the event logs
|
// TRANSLATORS: This is the date in the event logs
|
||||||
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
||||||
"<b>" + activity_day.DateTime.ToString (_("ddd MMM d, yyyy")) + "</b>");
|
"<b>" + activity_day.DateTime.ToString (_("ddd MMM d, yyyy")) + "</b>");
|
||||||
} else {
|
|
||||||
|
|
||||||
|
} else {
|
||||||
// TRANSLATORS: This is the date in the event logs, without the year
|
// TRANSLATORS: This is the date in the event logs, without the year
|
||||||
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
day_entry = day_entry_html.Replace ("<!-- $day-entry-header -->",
|
||||||
"<b>" + activity_day.DateTime.ToString (_("ddd MMM d")) + "</b>");
|
"<b>" + activity_day.DateTime.ToString (_("ddd MMM d")) + "</b>");
|
||||||
|
@ -486,6 +473,7 @@ namespace SparkleShare {
|
||||||
OnSyncing ();
|
OnSyncing ();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (repo.HasUnsyncedChanges) {
|
} else if (repo.HasUnsyncedChanges) {
|
||||||
if (OnError != null)
|
if (OnError != null)
|
||||||
OnError ();
|
OnError ();
|
||||||
|
@ -507,10 +495,6 @@ namespace SparkleShare {
|
||||||
// Adds a repository to the list of repositories
|
// Adds a repository to the list of repositories
|
||||||
private void AddRepository (string folder_path)
|
private void AddRepository (string folder_path)
|
||||||
{
|
{
|
||||||
// TODO: determine the backend type here.
|
|
||||||
// need to keep track of a table with folder+backendtype
|
|
||||||
// and use GitBackend.IsValidFolder (string path);
|
|
||||||
|
|
||||||
if (folder_path.Equals (SparklePaths.SparkleTmpPath))
|
if (folder_path.Equals (SparklePaths.SparkleTmpPath))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -564,8 +548,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (repo.Name.Equals (folder_name)) {
|
if (repo.Name.Equals (folder_name)) {
|
||||||
repo.Dispose ();
|
repo.Dispose ();
|
||||||
repo = null;
|
|
||||||
Repositories.Remove (repo);
|
Repositories.Remove (repo);
|
||||||
|
repo = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -774,6 +758,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
XmlNode node = xml.SelectSingleNode("//user/email/text()");
|
XmlNode node = xml.SelectSingleNode("//user/email/text()");
|
||||||
return node.Value;
|
return node.Value;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
string keys_path = SparklePaths.SparkleKeysPath;
|
string keys_path = SparklePaths.SparkleKeysPath;
|
||||||
|
|
||||||
|
@ -877,6 +862,7 @@ namespace SparkleShare {
|
||||||
TextWriter writer = File.AppendText (ssh_config_file_path);
|
TextWriter writer = File.AppendText (ssh_config_file_path);
|
||||||
writer.WriteLine (ssh_config);
|
writer.WriteLine (ssh_config);
|
||||||
writer.Close ();
|
writer.Close ();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
TextWriter writer = new StreamWriter (ssh_config_file_path);
|
TextWriter writer = new StreamWriter (ssh_config_file_path);
|
||||||
writer.WriteLine (ssh_config);
|
writer.WriteLine (ssh_config);
|
||||||
|
@ -908,6 +894,7 @@ namespace SparkleShare {
|
||||||
bool has_some_ssh_config = new Regex (@"[a-z]").IsMatch (current_ssh_config);
|
bool has_some_ssh_config = new Regex (@"[a-z]").IsMatch (current_ssh_config);
|
||||||
if (!has_some_ssh_config) {
|
if (!has_some_ssh_config) {
|
||||||
File.Delete (ssh_config_file_path);
|
File.Delete (ssh_config_file_path);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
TextWriter writer = new StreamWriter (ssh_config_file_path);
|
TextWriter writer = new StreamWriter (ssh_config_file_path);
|
||||||
writer.WriteLine (current_ssh_config);
|
writer.WriteLine (current_ssh_config);
|
||||||
|
@ -936,6 +923,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (File.Exists (avatar_file_path)) {
|
if (File.Exists (avatar_file_path)) {
|
||||||
return avatar_file_path;
|
return avatar_file_path;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Let's try to get the person's gravatar for next time
|
// Let's try to get the person's gravatar for next time
|
||||||
WebClient web_client = new WebClient ();
|
WebClient web_client = new WebClient ();
|
||||||
|
@ -989,16 +977,23 @@ namespace SparkleShare {
|
||||||
string canonical_name = Path.GetFileNameWithoutExtension (name);
|
string canonical_name = Path.GetFileNameWithoutExtension (name);
|
||||||
string tmp_folder = Path.Combine (SparklePaths.SparkleTmpPath, canonical_name);
|
string tmp_folder = Path.Combine (SparklePaths.SparkleTmpPath, canonical_name);
|
||||||
|
|
||||||
SparkleFetcherBase fetcher = new SparkleFetcherGit (url, tmp_folder);
|
SparkleFetcherBase fetcher;
|
||||||
bool folder_exists = Directory.Exists (Path.Combine (SparklePaths.SparklePath, canonical_name));
|
if (url.EndsWith (".hg")) {
|
||||||
|
url = url.Substring (0, (url.Length - 3));
|
||||||
|
fetcher = new SparkleFetcherHg (url, tmp_folder);
|
||||||
|
} else {
|
||||||
|
fetcher = new SparkleFetcherGit (url, tmp_folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool target_folder_exists = Directory.Exists (Path.Combine (SparklePaths.SparklePath, canonical_name));
|
||||||
|
|
||||||
// Add a numbered suffix to the nameif a folder with the same name
|
// Add a numbered suffix to the nameif a folder with the same name
|
||||||
// already exists. Example: "Folder (2)"
|
// already exists. Example: "Folder (2)"
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (folder_exists) {
|
while (target_folder_exists) {
|
||||||
i++;
|
i++;
|
||||||
folder_exists = Directory.Exists (
|
target_folder_exists = Directory.Exists (
|
||||||
SparkleHelpers.CombineMore (SparklePaths.SparklePath, canonical_name + " (" + i + ")"));
|
Path.Combine (SparklePaths.SparklePath, canonical_name + " (" + i + ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
string target_folder_name = canonical_name;
|
string target_folder_name = canonical_name;
|
||||||
|
@ -1016,6 +1011,16 @@ namespace SparkleShare {
|
||||||
target_folder_name);
|
target_folder_name);
|
||||||
|
|
||||||
Directory.Move (tmp_folder, target_folder_path);
|
Directory.Move (tmp_folder, target_folder_path);
|
||||||
|
AddRepository (target_folder_path);
|
||||||
|
|
||||||
|
if (FolderListChanged != null)
|
||||||
|
FolderListChanged ();
|
||||||
|
|
||||||
|
FolderSize = GetFolderSize ();
|
||||||
|
|
||||||
|
if (FolderSizeChanged != null)
|
||||||
|
FolderSizeChanged (FolderSize);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SparkleHelpers.DebugInfo ("Controller", "Error moving folder: " + e.Message);
|
SparkleHelpers.DebugInfo ("Controller", "Error moving folder: " + e.Message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue