diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index cd80150e..c7d3cdae 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -169,6 +169,8 @@ namespace SparkleLib { foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) folders.Add (node_folder ["name"].InnerText); + folders.Sort (); + return folders; } } diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 6bf153d8..4711e1f4 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -90,8 +90,6 @@ namespace SparkleShare { public List Folders { get { List folders = this.config.Folders; - folders.Sort (); - return folders; } } @@ -313,6 +311,7 @@ namespace SparkleShare { lock (this.check_repos_lock) { string path = this.config.FoldersPath; + // Detect any renames foreach (string folder_path in Directory.GetDirectories (path)) { string folder_name = Path.GetFileName (folder_path); @@ -340,6 +339,7 @@ namespace SparkleShare { } } + // Remove any deleted folders foreach (string folder_name in this.config.Folders) { string folder_path = new SparkleFolder (folder_name).FullPath; @@ -347,14 +347,22 @@ namespace SparkleShare { this.config.RemoveFolder (folder_name); RemoveRepository (folder_path); - SparkleLogger.LogInfo ("Controller", - "Removed folder '" + folder_name + "' from config"); + SparkleLogger.LogInfo ("Controller", "Removed folder '" + folder_name + "' from config"); } else { AddRepository (folder_path); } } + // Remove any duplicate folders + string previous_name = ""; + foreach (string folder_name in this.config.Folders) { + if (!string.IsNullOrEmpty (previous_name) && folder_name.Equals (previous_name)) + this.config.RemoveFolder (folder_name); + else + previous_name = folder_name; + } + FolderListChanged (); } }