From 19a1eba8dd88f2fa627c614d7852ee950592d061 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 9 May 2011 00:44:29 +0100 Subject: [PATCH] backend: Add IsUsablePath method and adjust related TODOs --- SparkleLib/SparkleBackend.cs | 10 +++++++++- SparkleShare/SparkleController.cs | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SparkleLib/SparkleBackend.cs b/SparkleLib/SparkleBackend.cs index 58c3f0c4..7be7c35a 100644 --- a/SparkleLib/SparkleBackend.cs +++ b/SparkleLib/SparkleBackend.cs @@ -20,6 +20,8 @@ using System.IO; namespace SparkleLib { + // An inheritable class that contains information + // about a backend public class SparkleBackend { public static SparkleBackend DefaultBackend; @@ -41,10 +43,16 @@ namespace SparkleLib { } - public bool IsPresent { + virtual public bool IsPresent { get { return (Path != null); } } + + + virtual public bool IsUsablePath (string path) + { + return (path.Length > 0); + } } } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index ac6a4a2b..8f0a4f94 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -135,9 +135,11 @@ namespace SparkleShare { FolderSizeChanged (FolderSize); }; + // TODO: Only support removing because 1. removing causes crashes and 2. Backend will be determined in + // the Intro and added to a table with the repo type, so we wont' know what type will be added + // Add the repository when a create event occurs watcher.Created += delegate (object o, FileSystemEventArgs args) { - // TODO: Needs to wait until the copying over is done // Handle invitations when the user saves an // invitation into the SparkleShare folder @@ -472,10 +474,15 @@ namespace SparkleShare { // Adds a repository to the list of repositories private void AddRepository (string folder_path) { - // Check if the folder is a Git repository + // TODO: determine the backend type here + // need to keep track of a table with folder+backendtype + // and use GitBackend.IsValidFolder (string path); + + // Check if the folder is a Git repository TODO: remove later if (!SparkleRepo.IsRepo (folder_path)) return; + SparkleRepo repo = new SparkleRepo (folder_path, SparkleBackend.DefaultBackend); repo.NewCommit += delegate (SparkleCommit commit, string repository_path) {