diff --git a/SparkleLib/SparkleHelpers.cs b/SparkleLib/SparkleHelpers.cs index 741648d7..86fa20c8 100755 --- a/SparkleLib/SparkleHelpers.cs +++ b/SparkleLib/SparkleHelpers.cs @@ -65,10 +65,19 @@ namespace SparkleLib { string [] files = Directory .GetFiles(path); foreach (string file in files) - File.SetAttributes (file, FileAttributes.Normal); + if (!IsSymlink (file)) + File.SetAttributes (file, FileAttributes.Normal); } } + // Check if a file is a symbolic link + public static bool IsSymlink (string file) + { + FileAttributes attr = File.GetAttributes (file); + + return ((attr & FileAttributes.ReparsePoint) == + FileAttributes.ReparsePoint); + } // Converts a UNIX timestamp to a more usable time object public static DateTime UnixTimestampToDateTime (int timestamp) diff --git a/SparkleLib/SparkleListenerTcp.cs b/SparkleLib/SparkleListenerTcp.cs index ee82127a..15274b9b 100755 --- a/SparkleLib/SparkleListenerTcp.cs +++ b/SparkleLib/SparkleListenerTcp.cs @@ -113,6 +113,8 @@ namespace SparkleLib { } catch (SocketException e) { SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message); + + OnDisconnected (); } }) ); @@ -132,8 +134,14 @@ namespace SparkleLib { string to_send = "subscribe " + folder_identifier + "\n"; - lock (this.mutex) { - this.socket.Send (Encoding.UTF8.GetBytes (to_send)); + try { + + lock (this.mutex) { + this.socket.Send (Encoding.UTF8.GetBytes (to_send)); + } + } catch (SocketException e) { + SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message); + OnDisconnected (); } } } @@ -145,8 +153,15 @@ namespace SparkleLib { string to_send = "announce " + announcement.FolderIdentifier + " " + announcement.Message + "\n"; - lock (this.mutex) { - this.socket.Send (Encoding.UTF8.GetBytes (to_send)); + try { + + lock (this.mutex) { + this.socket.Send (Encoding.UTF8.GetBytes (to_send)); + } + } catch (SocketException e) { + SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message); + + OnDisconnected (); } }