repo: Fix edge case where ID may be empty

This commit is contained in:
Hylke Bons 2012-05-19 16:15:20 +01:00
parent 0037013ca3
commit 1a97616e38
4 changed files with 19 additions and 30 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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 {

View file

@ -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;
}
}
}