From 6dd657a086d58dc622e2e2b60fe4135c02f0c3e2 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 19 May 2012 16:15:20 +0100 Subject: [PATCH] repo: Fix edge case where ID may be empty --- SparkleLib/Git/SparkleRepoGit.cs | 14 +------------- SparkleLib/SparkleListenerBase.cs | 2 +- SparkleLib/SparkleListenerTcp.cs | 3 --- SparkleLib/SparkleRepoBase.cs | 30 +++++++++++++++++------------- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 2b1b2e6f..fa48445c 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -157,8 +157,7 @@ namespace SparkleLib.Git { } - public override bool HasRemoteChanges - { + public override bool HasRemoteChanges { get { SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Checking for remote changes..."); SparkleGit git = new SparkleGit (LocalPath, "ls-remote \"" + RemoteUrl + "\" master"); @@ -393,17 +392,6 @@ namespace SparkleLib.Git { } - // Removes unneeded objects -/* private void CollectGarbage () - { - SparkleGit git = new SparkleGit (LocalPath, "gc"); - git.Start (); - git.WaitForExit (); - - SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Garbage collected."); - } */ - - // Commits the made changes private void Commit (string message) { diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/SparkleListenerBase.cs index 5e92143a..c7e16b4b 100755 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/SparkleListenerBase.cs @@ -109,7 +109,7 @@ namespace SparkleLib { { if (!this.channels.Contains (channel) && IsConnected) { SparkleHelpers.DebugInfo ("Listener", - "Subscribing to channel " + channel); + "Subscribing to channel " + channel + " on " + Server); this.channels.Add (channel); AlsoListenToInternal (channel); diff --git a/SparkleLib/SparkleListenerTcp.cs b/SparkleLib/SparkleListenerTcp.cs index 956c9757..5d7c6054 100755 --- a/SparkleLib/SparkleListenerTcp.cs +++ b/SparkleLib/SparkleListenerTcp.cs @@ -205,9 +205,6 @@ namespace SparkleLib { protected override void AlsoListenToInternal (string folder_identifier) { - SparkleHelpers.DebugInfo ("ListenerTcp", - "Subscribing to channel " + folder_identifier + " on " + Server); - string to_send = "subscribe " + folder_identifier + "\n"; try { diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 4c3bce17..632b8927 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -139,20 +139,24 @@ namespace SparkleLib { public string Identifier { get { - if (this.identifier == null) { - string id_path = Path.Combine (LocalPath, ".sparkleshare"); - - if (File.Exists (id_path)) { - this.identifier = File.ReadAllText (id_path).Trim (); - - } else { - this.identifier = ComputeIdentifier (); - File.WriteAllText (id_path, this.identifier); - File.SetAttributes (id_path, FileAttributes.Hidden); - } - } + if (this.identifier != null) + return this.identifier; + + string id_path = Path.Combine (LocalPath, ".sparkleshare"); - return this.identifier; + if (File.Exists (id_path)) + this.identifier = File.ReadAllText (id_path).Trim (); + + if (this.identifier != null && this.identifier.Length > 0) { + return this.identifier; + + } else { + this.identifier = ComputeIdentifier (); + File.WriteAllText (id_path, this.identifier); + File.SetAttributes (id_path, FileAttributes.Hidden); + + return this.identifier; + } } }