parent
82a88cb504
commit
a1d5054af4
|
@ -20,6 +20,7 @@ using System.IO;
|
|||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
|
||||
using SparkleLib;
|
||||
|
||||
namespace SparkleLib.Git {
|
||||
|
@ -33,10 +34,13 @@ namespace SparkleLib.Git {
|
|||
public SparkleFetcher (string server, string remote_path, string target_folder) :
|
||||
base (server, remote_path, target_folder)
|
||||
{
|
||||
//server = server.Trim ("/".ToCharArray ());
|
||||
remote_path = remote_path.Trim ("/".ToCharArray ());
|
||||
|
||||
if (server.EndsWith ("/"))
|
||||
server = server.Substring (0, server.Length - 1);
|
||||
|
||||
// FIXME: Adding these lines makes the fetcher fail
|
||||
//FIXME: Adding these lines makes the fetcher fail
|
||||
// if (remote_path.EndsWith ("/"))
|
||||
// remote_path = remote_path.Substring (0, remote_path.Length - 1);
|
||||
|
||||
|
@ -97,7 +101,7 @@ namespace SparkleLib.Git {
|
|||
this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
|
||||
"clone " +
|
||||
"--progress " + // Redirects progress stats to standarderror
|
||||
"\"" + RemoteUrl + "\" " + "\"" + SparkleHelpers.NormalizeSeparatorsToOS(TargetFolder) + "\"");
|
||||
"\"" + RemoteUrl + "\" \"" + TargetFolder + "\"");
|
||||
|
||||
this.git.StartInfo.RedirectStandardError = true;
|
||||
this.git.Start ();
|
||||
|
|
|
@ -109,18 +109,6 @@ namespace SparkleLib {
|
|||
|| platform == PlatformID.Win32Windows);
|
||||
}
|
||||
}
|
||||
|
||||
public static string NormalizeSeparatorsToOS(string path)
|
||||
{
|
||||
if (IsWindows)
|
||||
{
|
||||
return path.Replace('\\', '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -179,10 +179,18 @@ namespace SparkleShare {
|
|||
|
||||
tree.AppendColumn (service_column);
|
||||
|
||||
Entry address_entry = new Entry ();
|
||||
Entry path_entry = new Entry ();
|
||||
Label address_example = new Label ("1") { Xalign = 0, UseMarkup = true };
|
||||
Label path_example = new Label ("2") { Xalign = 0, UseMarkup = true };
|
||||
Entry address_entry = new Entry () {
|
||||
Text = Controller.PreviousAddress,
|
||||
Sensitive = (SelectedPlugin.Address == null)
|
||||
};
|
||||
|
||||
Entry path_entry = new Entry () {
|
||||
Text = Controller.PreviousPath,
|
||||
Sensitive = (SelectedPlugin.Path == null)
|
||||
};
|
||||
|
||||
Label address_example = new Label ("1") { Xalign = 0, UseMarkup = true };
|
||||
Label path_example = new Label ("2") { Xalign = 0, UseMarkup = true };
|
||||
|
||||
|
||||
// Select the first plugin by default
|
||||
|
@ -199,7 +207,6 @@ namespace SparkleShare {
|
|||
address_entry.Sensitive = (state == FieldState.Enabled);
|
||||
address_example.Markup = "<span size=\"small\" fgcolor=\""
|
||||
+ SecondaryTextColor + "\">" + example_text + "</span>";
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -941,44 +941,37 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void FetchFolder (string server, string remote_folder, string announcements_url)
|
||||
public void FetchFolder (string address, string remote_path, string announcements_url)
|
||||
{
|
||||
server = server.Trim ();
|
||||
remote_folder = remote_folder.Trim ();
|
||||
|
||||
if (announcements_url != null)
|
||||
announcements_url = announcements_url.Trim ();
|
||||
|
||||
|
||||
string tmp_path = SparkleConfig.DefaultConfig.TmpPath;
|
||||
if (!Directory.Exists (tmp_path)) {
|
||||
|
||||
if (!Directory.Exists (tmp_path)) {
|
||||
Directory.CreateDirectory (tmp_path);
|
||||
File.SetAttributes (tmp_path, FileAttributes.Directory | FileAttributes.Hidden);
|
||||
}
|
||||
|
||||
|
||||
// Strip the '.git' from the name
|
||||
string canonical_name = Path.GetFileNameWithoutExtension (remote_folder);
|
||||
string canonical_name = Path.GetFileNameWithoutExtension (remote_path);
|
||||
string tmp_folder = Path.Combine (tmp_path, canonical_name);
|
||||
string backend = Path.GetExtension (remote_folder);
|
||||
|
||||
string backend = Path.GetExtension (remote_path);
|
||||
|
||||
if (!string.IsNullOrEmpty (backend)) {
|
||||
backend = backend.Substring (1);
|
||||
|
||||
backend = backend.Substring (1);
|
||||
char [] letters = backend.ToCharArray ();
|
||||
letters [0] = char.ToUpper (letters [0]);
|
||||
backend = new string (letters);
|
||||
letters [0] = char.ToUpper (letters [0]);
|
||||
backend = new string (letters);
|
||||
|
||||
} else {
|
||||
backend = "Git";
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
this.fetcher = (SparkleFetcherBase) Activator.CreateInstance (
|
||||
Type.GetType ("SparkleLib." + backend + ".SparkleFetcher, SparkleLib." + backend),
|
||||
server,
|
||||
remote_folder,
|
||||
address,
|
||||
remote_path,
|
||||
tmp_folder
|
||||
);
|
||||
|
||||
|
@ -987,16 +980,15 @@ namespace SparkleShare {
|
|||
"Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\"");
|
||||
|
||||
if (FolderFetchError != null)
|
||||
FolderFetchError (Path.Combine (server, remote_folder).Replace (@"\", "/"));
|
||||
FolderFetchError (Path.Combine (address, remote_path).Replace (@"\", "/"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool target_folder_exists = Directory.Exists (
|
||||
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, canonical_name));
|
||||
|
||||
// Add a numbered suffix to the nameif a folder with the same name
|
||||
// Add a numbered suffix to the name if a folder with the same name
|
||||
// already exists. Example: "Folder (2)"
|
||||
int i = 1;
|
||||
while (target_folder_exists) {
|
||||
|
@ -1051,11 +1043,10 @@ namespace SparkleShare {
|
|||
FolderFetchError (this.fetcher.RemoteUrl);
|
||||
|
||||
this.fetcher.Dispose ();
|
||||
this.fetcher = null;
|
||||
|
||||
if (Directory.Exists (tmp_path))
|
||||
Directory.Delete (tmp_path, true);
|
||||
|
||||
this.fetcher = null;
|
||||
};
|
||||
|
||||
this.fetcher.ProgressChanged += delegate (double percentage) {
|
||||
|
@ -1063,7 +1054,6 @@ namespace SparkleShare {
|
|||
FolderFetching (percentage);
|
||||
};
|
||||
|
||||
|
||||
this.fetcher.Start ();
|
||||
}
|
||||
|
||||
|
|
|
@ -162,8 +162,6 @@ namespace SparkleShare {
|
|||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
|
||||
SelectedPluginChanged (SelectedPluginIndex);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -271,6 +269,7 @@ namespace SparkleShare {
|
|||
} else if (SelectedPlugin.AddressExample != null) {
|
||||
if (ChangeAddressFieldEvent != null)
|
||||
ChangeAddressFieldEvent (this.saved_address, SelectedPlugin.AddressExample, FieldState.Enabled);
|
||||
|
||||
} else {
|
||||
if (ChangeAddressFieldEvent != null)
|
||||
ChangeAddressFieldEvent (this.saved_address, "", FieldState.Enabled);
|
||||
|
@ -293,9 +292,6 @@ namespace SparkleShare {
|
|||
|
||||
public void CheckAddPage (string address, string remote_path, int selected_plugin)
|
||||
{
|
||||
if (SelectedPluginIndex != selected_plugin)
|
||||
SelectedPluginChanged (selected_plugin);
|
||||
|
||||
address = address.Trim ();
|
||||
remote_path = remote_path.Trim ();
|
||||
|
||||
|
@ -304,8 +300,10 @@ namespace SparkleShare {
|
|||
|
||||
this.saved_remote_path = remote_path;
|
||||
|
||||
bool fields_valid = address != null && address.Trim ().Length > 0 &&
|
||||
remote_path != null && remote_path.Trim ().Length > 0;
|
||||
bool fields_valid = (address != null &&
|
||||
address.Trim ().Length > 0 &&
|
||||
remote_path != null &&
|
||||
remote_path.Trim ().Length > 0);
|
||||
|
||||
if (UpdateAddProjectButtonEvent != null)
|
||||
UpdateAddProjectButtonEvent (fields_valid);
|
||||
|
@ -314,6 +312,10 @@ namespace SparkleShare {
|
|||
|
||||
public void AddPageCompleted (string address, string remote_path)
|
||||
{
|
||||
address = address.Trim ();
|
||||
remote_path = remote_path.Trim ();
|
||||
remote_path = remote_path.TrimEnd ("/".ToCharArray ());
|
||||
|
||||
SyncingFolder = Path.GetFileNameWithoutExtension (remote_path);
|
||||
PreviousAddress = address;
|
||||
PreviousPath = remote_path;
|
||||
|
|
|
@ -291,7 +291,8 @@ namespace SparkleShare {
|
|||
|
||||
TextBox address_box = new TextBox () {
|
||||
Width = 200,
|
||||
Text = Controller.PreviousAddress
|
||||
Text = Controller.PreviousAddress,
|
||||
IsEnabled = (Controller.SelectedPlugin.Address == null)
|
||||
};
|
||||
|
||||
TextBlock address_help_label = new TextBlock () {
|
||||
|
@ -308,7 +309,8 @@ namespace SparkleShare {
|
|||
|
||||
TextBox path_box = new TextBox () {
|
||||
Width = 200,
|
||||
Text = Controller.PreviousPath
|
||||
Text = Controller.PreviousPath,
|
||||
IsEnabled = (Controller.SelectedPlugin.Path == null)
|
||||
};
|
||||
|
||||
TextBlock path_help_label = new TextBlock () {
|
||||
|
@ -361,6 +363,7 @@ namespace SparkleShare {
|
|||
address_box.Focus ();
|
||||
address_box.Select (address_box.Text.Length, 0);
|
||||
|
||||
|
||||
Controller.ChangeAddressFieldEvent += delegate (string text,
|
||||
string example_text, FieldState state) {
|
||||
|
||||
|
@ -394,21 +397,15 @@ namespace SparkleShare {
|
|||
list_view.KeyDown += delegate {
|
||||
Controller.SelectedPluginChanged (list_view.SelectedIndex);
|
||||
};
|
||||
|
||||
Controller.CheckAddPage (address_box.Text, path_box.Text, list_view.SelectedIndex);
|
||||
|
||||
address_box.TextChanged += delegate {
|
||||
Controller.CheckAddPage (
|
||||
address_box.Text,
|
||||
path_box.Text,
|
||||
list_view.SelectedIndex
|
||||
);
|
||||
Controller.CheckAddPage (address_box.Text, path_box.Text, list_view.SelectedIndex);
|
||||
};
|
||||
|
||||
path_box.TextChanged += delegate {
|
||||
Controller.CheckAddPage (
|
||||
address_box.Text,
|
||||
path_box.Text,
|
||||
list_view.SelectedIndex
|
||||
);
|
||||
Controller.CheckAddPage (address_box.Text, path_box.Text, list_view.SelectedIndex);
|
||||
};
|
||||
|
||||
cancel_button.Click += delegate {
|
||||
|
@ -418,13 +415,7 @@ namespace SparkleShare {
|
|||
add_button.Click += delegate {
|
||||
Controller.AddPageCompleted (address_box.Text, path_box.Text);
|
||||
};
|
||||
|
||||
Controller.CheckAddPage (
|
||||
address_box.Text,
|
||||
path_box.Text,
|
||||
list_view.SelectedIndex
|
||||
);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue