Skip to content

Implementing a backend

hbons edited this page Feb 9, 2012 · 32 revisions

Implementing a backend

By default, SparkleShare uses Git to store and sync files. However, you can implement a custom backend to suit your needs with relative ease. It's possible to use some other version control system or some other custom protocol. This page tries to explain how to go about this.

Overview

There are two classes that need implementing to get a working backend:

  • SparkleFetcherBase: takes care of the initial fetching of a remote repository;
  • SparkleRepoBase: implements the syncing algorithm to keep up the client to date with the remote repository.

SparkleRepoBase

// Constructors
public SparkleRepoGit (string path);

// Methods
public abstract bool SyncUp ();
public abstract bool SyncDown ();
public abstract List<SparkleChangeSet> GetChangeSets (int count);
protected void OnProgressChanged (double progress_percentage, string progress_speed);

// Properties
public abstract string Identifier { get; }
public abstract string CurrentRevision { get; }
public abstract bool HasRemoteChanges { get; }
public abstract bool HasLocalChanges { get; }
public abstract double Size { get; }
public abstract double HistorySize { get; }

SparkleFetcherBase

// Constructors
public SparkleFetcherBase (string server, string remote_folder, string target_folder);

// Methods
public abstract bool Fetch ();
public abstract void Stop ();
protected void OnProgressChanged (double percentage);

// Properties
public abstract string [] Warnings { get; }