Add initial support for different storage types
This commit is contained in:
parent
556220ffa0
commit
b79c3ea3d0
|
@ -582,6 +582,13 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetcher.Finished += delegate (bool repo_is_encrypted, bool repo_is_empty, string [] warnings) {
|
this.fetcher.Finished += delegate (bool repo_is_encrypted, bool repo_is_empty, string [] warnings) {
|
||||||
|
|
||||||
|
if (repo_is_empty) {
|
||||||
|
ShowSetupWindow (PageType.StorageSetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
return; // TODO
|
||||||
|
|
||||||
if (repo_is_encrypted && repo_is_empty) {
|
if (repo_is_encrypted && repo_is_empty) {
|
||||||
ShowSetupWindowEvent (PageType.CryptoSetup);
|
ShowSetupWindowEvent (PageType.CryptoSetup);
|
||||||
|
|
||||||
|
@ -620,10 +627,24 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
return this.fetcher.IsFetchedRepoPasswordCorrect (password);
|
return this.fetcher.IsFetchedRepoPasswordCorrect (password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void FinishFetcher (string password)
|
public void FinishFetcher (StorageType storage_type)
|
||||||
{
|
{
|
||||||
|
if (storage_type == StorageType.Media) {
|
||||||
|
FinishFetcher (); // TODO: enable large files
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FinishFetcher ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void FinishFetcher (StorageType storage_type, string password)
|
||||||
|
{
|
||||||
|
if (storage_type != StorageType.Encrypted)
|
||||||
|
return;
|
||||||
|
|
||||||
this.fetcher.EnableFetchedRepoCrypto (password);
|
this.fetcher.EnableFetchedRepoCrypto (password);
|
||||||
FinishFetcher ();
|
FinishFetcher ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<description>The biggest collection of Open Source projects</description>
|
<description>The biggest collection of Open Source projects</description>
|
||||||
<icon>github.png</icon>
|
<icon>github.png</icon>
|
||||||
<backend>Git</backend>
|
<backend>Git</backend>
|
||||||
|
<storage_type>LargeFiles</storage_type>
|
||||||
<fingerprint>9d:38:5b:83:a9:17:52:92:56:1a:5e:c4:d4:81:8e:0a:ca:51:a2:64:f1:74:20:11:2e:f8:8a:c3:a1:39:49:8f</fingerprint>
|
<fingerprint>9d:38:5b:83:a9:17:52:92:56:1a:5e:c4:d4:81:8e:0a:ca:51:a2:64:f1:74:20:11:2e:f8:8a:c3:a1:39:49:8f</fingerprint>
|
||||||
</info>
|
</info>
|
||||||
<address>
|
<address>
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace SparkleShare {
|
||||||
Error,
|
Error,
|
||||||
Finished,
|
Finished,
|
||||||
Tutorial,
|
Tutorial,
|
||||||
|
StorageSetup,
|
||||||
CryptoSetup,
|
CryptoSetup,
|
||||||
CryptoPassword
|
CryptoPassword
|
||||||
}
|
}
|
||||||
|
@ -500,6 +501,24 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void StoragePageCompleted (StorageType storage_type)
|
||||||
|
{
|
||||||
|
if (storage_type == StorageType.Encrypted) {
|
||||||
|
ChangePageEvent (PageType.CryptoSetup, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressBarPercentage = 100.0;
|
||||||
|
ChangePageEvent (PageType.Syncing, null);
|
||||||
|
|
||||||
|
new Thread (() => {
|
||||||
|
Thread.Sleep (1000);
|
||||||
|
SparkleShare.Controller.FinishFetcher (); // TODO:
|
||||||
|
|
||||||
|
}).Start ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void CheckCryptoSetupPage (string password)
|
public void CheckCryptoSetupPage (string password)
|
||||||
{
|
{
|
||||||
new Thread (() => {
|
new Thread (() => {
|
||||||
|
@ -535,7 +554,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
new Thread (() => {
|
new Thread (() => {
|
||||||
Thread.Sleep (1000);
|
Thread.Sleep (1000);
|
||||||
SparkleShare.Controller.FinishFetcher (password);
|
SparkleShare.Controller.FinishFetcher (StorageType.Encrypted, password);
|
||||||
|
|
||||||
}).Start ();
|
}).Start ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void AddHostedProjectClicked ()
|
public void AddHostedProjectClicked ()
|
||||||
{
|
{
|
||||||
new Thread (() => SparkleShare.Controller.ShowSetupWindow (PageType.Add)).Start ();
|
new Thread (() => SparkleShare.Controller.ShowSetupWindow (PageType.StorageSetup)).Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyToClipboardClicked ()
|
public void CopyToClipboardClicked ()
|
||||||
|
|
|
@ -468,6 +468,62 @@ namespace SparkleShare {
|
||||||
Add (points);
|
Add (points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == PageType.StorageSetup) {
|
||||||
|
Header = "Set up storage type";
|
||||||
|
Description = "What type of storage would you like to use?";
|
||||||
|
|
||||||
|
VBox layout_vertical = new VBox (false, 0);
|
||||||
|
|
||||||
|
var css_provider = new CssProvider ();
|
||||||
|
|
||||||
|
css_provider.LoadFromData ("GtkRadioButton {" +
|
||||||
|
"font-weight: bold;" +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
RadioButton radio_plain = new RadioButton (null, "Plain Storage") { Active = true };
|
||||||
|
Label label_plain = new Label ("Nothing fancy.") { Xalign = 0 };
|
||||||
|
|
||||||
|
RadioButton radio_large_files = new RadioButton (radio_plain, "Media Storage");
|
||||||
|
Label label_large_files = new Label ("Trade off versioning for space; don't keep a history locally.") { Xalign = 0 };
|
||||||
|
|
||||||
|
RadioButton radio_encrypted = new RadioButton (radio_plain, "Encrypted Storage");
|
||||||
|
Label label_encrypted = new Label ("Trade off efficiency for privacy; encrypt files before storing them.") { Xalign = 0 };
|
||||||
|
|
||||||
|
|
||||||
|
radio_plain.StyleContext.AddProvider (css_provider, 800);
|
||||||
|
radio_large_files.StyleContext.AddProvider (css_provider, 800);
|
||||||
|
radio_encrypted.StyleContext.AddProvider (css_provider, 800);
|
||||||
|
|
||||||
|
layout_vertical.PackStart (radio_plain, false, false, 6);
|
||||||
|
layout_vertical.PackStart (label_plain, false, false, 0);
|
||||||
|
layout_vertical.PackStart (radio_large_files, false, false, 6);
|
||||||
|
layout_vertical.PackStart (label_large_files, false, false, 0);
|
||||||
|
layout_vertical.PackStart (radio_encrypted, false, false, 6);
|
||||||
|
layout_vertical.PackStart (label_encrypted, false, false, 0);
|
||||||
|
|
||||||
|
Add (layout_vertical);
|
||||||
|
|
||||||
|
Button cancel_button = new Button ("Cancel");
|
||||||
|
Button continue_button = new Button ("Continue");
|
||||||
|
|
||||||
|
continue_button.Clicked += delegate {
|
||||||
|
if (radio_large_files.Active) {
|
||||||
|
Controller.StoragePageCompleted (StorageType.Media);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (radio_encrypted.Active) {
|
||||||
|
Controller.StoragePageCompleted (StorageType.Media);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller.StoragePageCompleted (StorageType.Plain);
|
||||||
|
};
|
||||||
|
|
||||||
|
AddButton (cancel_button);
|
||||||
|
AddButton (continue_button);
|
||||||
|
}
|
||||||
|
|
||||||
if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) {
|
if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) {
|
||||||
if (type == PageType.CryptoSetup) {
|
if (type == PageType.CryptoSetup) {
|
||||||
Header = "Set up file encryption";
|
Header = "Set up file encryption";
|
||||||
|
|
|
@ -51,6 +51,8 @@ namespace Sparkles {
|
||||||
public abstract bool IsFetchedRepoPasswordCorrect (string password);
|
public abstract bool IsFetchedRepoPasswordCorrect (string password);
|
||||||
public abstract void EnableFetchedRepoCrypto (string password);
|
public abstract void EnableFetchedRepoCrypto (string password);
|
||||||
|
|
||||||
|
protected readonly List<StorageTypeInfo> AvailableStorageTypes = new List<StorageTypeInfo> ();
|
||||||
|
|
||||||
public double ProgressPercentage { get; private set; }
|
public double ProgressPercentage { get; private set; }
|
||||||
public double ProgressSpeed { get; private set; }
|
public double ProgressSpeed { get; private set; }
|
||||||
|
|
||||||
|
@ -109,6 +111,9 @@ namespace Sparkles {
|
||||||
|
|
||||||
protected BaseFetcher (SparkleFetcherInfo info)
|
protected BaseFetcher (SparkleFetcherInfo info)
|
||||||
{
|
{
|
||||||
|
AvailableStorageTypes.Add (
|
||||||
|
new StorageTypeInfo (StorageType.Plain, "Plain Storage", "Nothing fancy."));
|
||||||
|
|
||||||
OriginalFetcherInfo = info;
|
OriginalFetcherInfo = info;
|
||||||
RequiredFingerprint = info.Fingerprint;
|
RequiredFingerprint = info.Fingerprint;
|
||||||
FetchPriorHistory = info.FetchPriorHistory;
|
FetchPriorHistory = info.FetchPriorHistory;
|
||||||
|
|
|
@ -24,11 +24,29 @@ using Timers = System.Timers;
|
||||||
|
|
||||||
namespace Sparkles {
|
namespace Sparkles {
|
||||||
|
|
||||||
public enum RepositoryStorageType {
|
public enum StorageType {
|
||||||
|
Unknown,
|
||||||
Plain,
|
Plain,
|
||||||
Encrypted,
|
Media,
|
||||||
LargeFiles,
|
Encrypted
|
||||||
LargeFilesEncrypted
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class StorageTypeInfo {
|
||||||
|
|
||||||
|
public readonly StorageType Type;
|
||||||
|
|
||||||
|
public readonly string Name;
|
||||||
|
public readonly string Description;
|
||||||
|
|
||||||
|
|
||||||
|
public StorageTypeInfo (StorageType storage_type, string name, string description)
|
||||||
|
{
|
||||||
|
Type = storage_type;
|
||||||
|
|
||||||
|
Name = name;
|
||||||
|
Description = description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SyncStatus {
|
public enum SyncStatus {
|
||||||
|
@ -69,7 +87,7 @@ namespace Sparkles {
|
||||||
public abstract List<ChangeSet> GetChangeSets ();
|
public abstract List<ChangeSet> GetChangeSets ();
|
||||||
public abstract List<ChangeSet> GetChangeSets (string path);
|
public abstract List<ChangeSet> GetChangeSets (string path);
|
||||||
|
|
||||||
protected RepositoryStorageType StorageType = RepositoryStorageType.Plain;
|
protected StorageType StorageType = StorageType.Plain;
|
||||||
|
|
||||||
public static bool UseCustomWatcher = false;
|
public static bool UseCustomWatcher = false;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace Sparkles.Git {
|
||||||
|
|
||||||
|
|
||||||
static string git_path;
|
static string git_path;
|
||||||
static string git_lfs_path;
|
|
||||||
|
|
||||||
public static string GitPath {
|
public static string GitPath {
|
||||||
get {
|
get {
|
||||||
|
@ -40,19 +39,6 @@ namespace Sparkles.Git {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GitLFSPath {
|
|
||||||
get {
|
|
||||||
if (git_lfs_path == null)
|
|
||||||
git_lfs_path = LocateCommand ("git-lfs");
|
|
||||||
|
|
||||||
return git_lfs_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
git_lfs_path = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static string GitVersion {
|
public static string GitVersion {
|
||||||
get {
|
get {
|
||||||
|
@ -64,12 +50,13 @@ namespace Sparkles.Git {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static string GitLFSVersion {
|
public static string GitLFSVersion {
|
||||||
get {
|
get {
|
||||||
if (GitLFSPath == null)
|
if (GitPath == null)
|
||||||
GitLFSPath = LocateCommand ("git-lfs");
|
GitPath = LocateCommand ("git");
|
||||||
|
|
||||||
string git_lfs_version = new Command (GitLFSPath, "version").StartAndReadStandardOutput ();
|
string git_lfs_version = new Command (GitPath, "lfs version").StartAndReadStandardOutput ();
|
||||||
return git_lfs_version.Replace ("git-lfs/", "").Split (' ') [0];
|
return git_lfs_version.Replace ("git-lfs/", "").Split (' ') [0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +82,6 @@ namespace Sparkles.Git {
|
||||||
if (ExecPath == null)
|
if (ExecPath == null)
|
||||||
SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath);
|
SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath);
|
||||||
|
|
||||||
Console.WriteLine (GIT_SSH_COMMAND);
|
|
||||||
|
|
||||||
SetEnvironmentVariable ("GIT_SSH_COMMAND", GIT_SSH_COMMAND);
|
SetEnvironmentVariable ("GIT_SSH_COMMAND", GIT_SSH_COMMAND);
|
||||||
SetEnvironmentVariable ("GIT_TERMINAL_PROMPT", "0");
|
SetEnvironmentVariable ("GIT_TERMINAL_PROMPT", "0");
|
||||||
SetEnvironmentVariable ("LANG", "en_US");
|
SetEnvironmentVariable ("LANG", "en_US");
|
||||||
|
@ -108,8 +93,9 @@ namespace Sparkles.Git {
|
||||||
return SSHPath + " " +
|
return SSHPath + " " +
|
||||||
"-i " + auth_info.PrivateKeyFilePath.Replace (" ", "\\ ") + " " +
|
"-i " + auth_info.PrivateKeyFilePath.Replace (" ", "\\ ") + " " +
|
||||||
"-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace (" ", "\\ ") + " " +
|
"-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace (" ", "\\ ") + " " +
|
||||||
"-o PasswordAuthentication=no " +
|
"-o IdentitiesOnly=yes" + " " + // Don't fall back to other keys on the system
|
||||||
"-F /dev/null"; // Ignore the environment's SSH config file
|
"-o PasswordAuthentication=no" + " " + // Don't hang on possible password prompts
|
||||||
|
"-F /dev/null"; // Ignore the system's SSH config file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,10 @@ namespace Sparkles.Git {
|
||||||
|
|
||||||
public GitFetcher (SparkleFetcherInfo fetcher_info, SSHAuthenticationInfo auth_info) : base (fetcher_info)
|
public GitFetcher (SparkleFetcherInfo fetcher_info, SSHAuthenticationInfo auth_info) : base (fetcher_info)
|
||||||
{
|
{
|
||||||
|
AvailableStorageTypes.Add (
|
||||||
|
new StorageTypeInfo (StorageType.Encrypted, "Encrypted Storage",
|
||||||
|
"Trade off efficiency for privacy; encrypt files before storing them."));
|
||||||
|
|
||||||
this.auth_info = auth_info;
|
this.auth_info = auth_info;
|
||||||
var uri_builder = new UriBuilder (RemoteUrl);
|
var uri_builder = new UriBuilder (RemoteUrl);
|
||||||
|
|
||||||
|
@ -55,6 +59,10 @@ namespace Sparkles.Git {
|
||||||
if (RemoteUrl.Host.Equals ("github.com") ||
|
if (RemoteUrl.Host.Equals ("github.com") ||
|
||||||
RemoteUrl.Host.Equals ("gitlab.com")) {
|
RemoteUrl.Host.Equals ("gitlab.com")) {
|
||||||
|
|
||||||
|
AvailableStorageTypes.Add (
|
||||||
|
new StorageTypeInfo (StorageType.Media, "Media Storage",
|
||||||
|
"Trade off versioning for space; don't keep a history locally."));
|
||||||
|
|
||||||
uri_builder.Scheme = "ssh";
|
uri_builder.Scheme = "ssh";
|
||||||
uri_builder.UserName = "git";
|
uri_builder.UserName = "git";
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,6 @@ namespace Sparkles.Git {
|
||||||
{
|
{
|
||||||
this.auth_info = auth_info;
|
this.auth_info = auth_info;
|
||||||
|
|
||||||
if (RemoteUrl.Host == "github.com") // TODO
|
|
||||||
StorageType = RepositoryStorageType.LargeFiles;
|
|
||||||
|
|
||||||
var git_config = new GitCommand (LocalPath, "config core.ignorecase false");
|
var git_config = new GitCommand (LocalPath, "config core.ignorecase false");
|
||||||
git_config.StartAndWaitForExit ();
|
git_config.StartAndWaitForExit ();
|
||||||
|
|
||||||
|
@ -231,7 +228,7 @@ namespace Sparkles.Git {
|
||||||
if (File.Exists (pre_push_hook_path))
|
if (File.Exists (pre_push_hook_path))
|
||||||
File.Delete (pre_push_hook_path);
|
File.Delete (pre_push_hook_path);
|
||||||
|
|
||||||
if (StorageType == RepositoryStorageType.LargeFiles) {
|
if (StorageType == StorageType.Media) {
|
||||||
// TODO: Progress reporting, error handling
|
// TODO: Progress reporting, error handling
|
||||||
var git_lfs_push = new GitCommand (LocalPath, "lfs push origin " + branch, auth_info);
|
var git_lfs_push = new GitCommand (LocalPath, "lfs push origin " + branch, auth_info);
|
||||||
git_lfs_push.StartAndWaitForExit ();
|
git_lfs_push.StartAndWaitForExit ();
|
||||||
|
@ -308,7 +305,7 @@ namespace Sparkles.Git {
|
||||||
|
|
||||||
public override bool SyncDown ()
|
public override bool SyncDown ()
|
||||||
{
|
{
|
||||||
if (StorageType == RepositoryStorageType.LargeFiles) {
|
if (StorageType == StorageType.Media) {
|
||||||
var git_lfs_pull = new GitCommand (LocalPath, "lfs pull", auth_info);
|
var git_lfs_pull = new GitCommand (LocalPath, "lfs pull", auth_info);
|
||||||
git_lfs_pull.StartAndWaitForExit ();
|
git_lfs_pull.StartAndWaitForExit ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue