From 73f58892e8446d752cffa25726267917417f712e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Vollst=C3=A4dt?= Date: Mon, 5 Sep 2011 17:34:07 +0200 Subject: [PATCH] Check readabilty only for existing files; Remove Exclusions when file is readable again --- SparkleLib/SparkleRepoBase.cs | 36 ++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 6af276d9..813891e0 100644 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -66,7 +66,7 @@ namespace SparkleLib { public abstract bool AddExclusionRule (FileSystemEventArgs args); public abstract bool RemoveExclusionRule (FileSystemEventArgs args); - public abstract bool CheckExclusionRules (); + public abstract bool ExclusionRuleExists (FileSystemEventArgs args); public delegate void SyncStatusChangedEventHandler (SyncStatus new_status); public event SyncStatusChangedEventHandler SyncStatusChanged; @@ -321,18 +321,36 @@ namespace SparkleLib { return; /* - * Check whether the file which triggered the action - * is readable so that git can actually commit it - */ - + * Check whether the file which triggered the action + * is readable so that git can actually commit it + */ try { - FileStream file = File.OpenRead(args.FullPath); - file.Close(); + if(File.Exists(args.FullPath)) { + FileStream file = File.OpenRead(args.FullPath); + file.Close(); + } } catch { - SparkleHelpers.DebugInfo("Warning", "File " + args.FullPath + " is not readable. Adding to ignore list."); - AddExclusionRule(args); + if(!ExclusionRuleExists(args)) { + SparkleHelpers.DebugInfo("Warning", "File " + args.FullPath + " is not readable. Adding to ignore list."); + AddExclusionRule(args); + } + return; } + + /* + * Remove rule if file is readable but there is still + * an exclusion rule set + */ + if(ExclusionRuleExists(args)) { + SparkleHelpers.DebugInfo("Info", "Removing exclusion rule for " + args.Name); + RemoveExclusionRule(args); + + // If a file was former unreadable but has now been (re)moved, skip the process. + if(!File.Exists(args.FullPath)) { + return; + } + } WatcherChangeTypes wct = args.ChangeType;