backend: Add IsUsablePath method and adjust related TODOs

This commit is contained in:
Hylke Bons 2011-05-09 00:44:29 +01:00
parent a29f7b32bc
commit 19a1eba8dd
2 changed files with 18 additions and 3 deletions

View file

@ -20,6 +20,8 @@ using System.IO;
namespace SparkleLib { namespace SparkleLib {
// An inheritable class that contains information
// about a backend
public class SparkleBackend { public class SparkleBackend {
public static SparkleBackend DefaultBackend; public static SparkleBackend DefaultBackend;
@ -41,10 +43,16 @@ namespace SparkleLib {
} }
public bool IsPresent { virtual public bool IsPresent {
get { get {
return (Path != null); return (Path != null);
} }
} }
virtual public bool IsUsablePath (string path)
{
return (path.Length > 0);
}
} }
} }

View file

@ -135,9 +135,11 @@ namespace SparkleShare {
FolderSizeChanged (FolderSize); 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 // Add the repository when a create event occurs
watcher.Created += delegate (object o, FileSystemEventArgs args) { watcher.Created += delegate (object o, FileSystemEventArgs args) {
// TODO: Needs to wait until the copying over is done
// Handle invitations when the user saves an // Handle invitations when the user saves an
// invitation into the SparkleShare folder // invitation into the SparkleShare folder
@ -472,10 +474,15 @@ namespace SparkleShare {
// Adds a repository to the list of repositories // Adds a repository to the list of repositories
private void AddRepository (string folder_path) 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)) if (!SparkleRepo.IsRepo (folder_path))
return; return;
SparkleRepo repo = new SparkleRepo (folder_path, SparkleBackend.DefaultBackend); SparkleRepo repo = new SparkleRepo (folder_path, SparkleBackend.DefaultBackend);
repo.NewCommit += delegate (SparkleCommit commit, string repository_path) { repo.NewCommit += delegate (SparkleCommit commit, string repository_path) {