Cleanup
This commit is contained in:
parent
b9e3c769d9
commit
013a8bff64
|
@ -112,7 +112,7 @@ namespace Sparkles {
|
|||
return this.identifier;
|
||||
|
||||
} else {
|
||||
string config_identifier = this.local_config.GetIdentifierForFolder (Name);
|
||||
string config_identifier = this.local_config.IdentifierByName (Name);
|
||||
|
||||
if (!string.IsNullOrEmpty (config_identifier))
|
||||
this.identifier = config_identifier;
|
||||
|
@ -160,7 +160,7 @@ namespace Sparkles {
|
|||
this.local_config = config;
|
||||
LocalPath = path;
|
||||
Name = Path.GetFileName (LocalPath);
|
||||
RemoteUrl = new Uri (this.local_config.GetUrlForFolder (Name));
|
||||
RemoteUrl = new Uri (this.local_config.UrlByName (Name));
|
||||
IsBuffering = false;
|
||||
this.identifier = Identifier;
|
||||
ChangeSets = GetChangeSets ();
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Sparkles {
|
|||
return Path.Combine (custom_path, Name);
|
||||
|
||||
return Path.Combine (Configuration.DefaultConfig.FoldersPath,
|
||||
new Uri (Configuration.DefaultConfig.GetUrlForFolder (Name)).Host,
|
||||
new Uri (Configuration.DefaultConfig.UrlByName (Name)).Host,
|
||||
Name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Sparkles {
|
|||
get {
|
||||
if (InstallationInfo.Platform == PlatformID.Win32NT)
|
||||
return Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
|
||||
else
|
||||
|
||||
return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace Sparkles {
|
|||
get {
|
||||
if (GetConfigOption ("folders_path") != null)
|
||||
return GetConfigOption ("folders_path");
|
||||
else
|
||||
|
||||
return Path.Combine (HomePath, "SparkleShare");
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace Sparkles {
|
|||
CreateInitialConfig ();
|
||||
|
||||
} catch (XmlException) {
|
||||
FileInfo file = new FileInfo (FullPath);
|
||||
var file = new FileInfo (FullPath);
|
||||
|
||||
if (file.Length == 0) {
|
||||
File.Delete (FullPath);
|
||||
|
@ -106,21 +106,17 @@ namespace Sparkles {
|
|||
}
|
||||
|
||||
|
||||
private void CreateInitialConfig ()
|
||||
void CreateInitialConfig ()
|
||||
{
|
||||
string user_name = "Unknown";
|
||||
string user_name = Environment.UserName;
|
||||
|
||||
if (InstallationInfo.Platform == PlatformID.Unix ||
|
||||
InstallationInfo.Platform == PlatformID.MacOSX) {
|
||||
|
||||
user_name = Environment.UserName;
|
||||
if (string.IsNullOrEmpty (user_name))
|
||||
user_name = "Unknown";
|
||||
else
|
||||
user_name = user_name.TrimEnd (",".ToCharArray ());
|
||||
|
||||
} else {
|
||||
user_name = Environment.UserName;
|
||||
user_name = user_name.TrimEnd (',');
|
||||
}
|
||||
|
||||
// TODO: Don't do this manually
|
||||
|
@ -139,23 +135,15 @@ namespace Sparkles {
|
|||
|
||||
public User User {
|
||||
get {
|
||||
XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
||||
XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
||||
|
||||
string name = name_node.Value;
|
||||
string email = email_node.Value;
|
||||
string name = SelectSingleNode ("/sparkleshare/user/name/text()").Value;
|
||||
string email = SelectSingleNode ("/sparkleshare/user/email/text()").Value;
|
||||
|
||||
return new User (name, email);
|
||||
}
|
||||
|
||||
set {
|
||||
User user = (User) value;
|
||||
|
||||
XmlNode name_node = SelectSingleNode ("/sparkleshare/user/name/text()");
|
||||
XmlNode email_node = SelectSingleNode ("/sparkleshare/user/email/text()");
|
||||
|
||||
name_node.InnerText = user.Name;
|
||||
email_node.InnerText = user.Email;
|
||||
SelectSingleNode ("/sparkleshare/user/name/text()").InnerText = value.Name;
|
||||
SelectSingleNode ("/sparkleshare/user/email/text()").InnerText = value.Email;
|
||||
|
||||
Save ();
|
||||
}
|
||||
|
@ -164,13 +152,12 @@ namespace Sparkles {
|
|||
|
||||
public List<string> Folders {
|
||||
get {
|
||||
List<string> folders = new List<string> ();
|
||||
var folders = new List<string> ();
|
||||
|
||||
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder"))
|
||||
folders.Add (node_folder ["name"].InnerText);
|
||||
|
||||
folders.Sort ();
|
||||
|
||||
return folders;
|
||||
}
|
||||
}
|
||||
|
@ -213,31 +200,31 @@ namespace Sparkles {
|
|||
}
|
||||
|
||||
|
||||
public void RenameFolder (string identifier, string name)
|
||||
public void RenameFolder (string identifier, string new_name)
|
||||
{
|
||||
XmlNode node_folder = SelectSingleNode (
|
||||
string.Format ("/sparkleshare/folder[identifier=\"{0}\"]", identifier));
|
||||
|
||||
node_folder ["name"].InnerText = name;
|
||||
node_folder ["name"].InnerText = new_name;
|
||||
Save ();
|
||||
}
|
||||
|
||||
|
||||
public string GetBackendForFolder (string name)
|
||||
public string BackendByName (string name)
|
||||
{
|
||||
return GetFolderValue (name, "backend");
|
||||
return FolderValueByKey (name, "backend");
|
||||
}
|
||||
|
||||
|
||||
public string GetIdentifierForFolder (string name)
|
||||
public string IdentifierByName (string name)
|
||||
{
|
||||
return GetFolderValue (name, "identifier");
|
||||
return FolderValueByKey (name, "identifier");
|
||||
}
|
||||
|
||||
|
||||
public string GetUrlForFolder (string name)
|
||||
public string UrlByName (string name)
|
||||
{
|
||||
return GetFolderValue (name, "url");
|
||||
return FolderValueByKey (name, "url");
|
||||
}
|
||||
|
||||
|
||||
|
@ -259,7 +246,7 @@ namespace Sparkles {
|
|||
|
||||
public bool SetFolderOptionalAttribute (string folder_name, string key, string value)
|
||||
{
|
||||
XmlNode folder = GetFolder (folder_name);
|
||||
XmlNode folder = FolderByName (folder_name);
|
||||
|
||||
if (folder == null)
|
||||
return false;
|
||||
|
@ -281,7 +268,7 @@ namespace Sparkles {
|
|||
|
||||
public string GetFolderOptionalAttribute (string folder_name, string key)
|
||||
{
|
||||
XmlNode folder = GetFolder (folder_name);
|
||||
XmlNode folder = FolderByName (folder_name);
|
||||
|
||||
if (folder != null) {
|
||||
if (folder [key] != null)
|
||||
|
@ -326,24 +313,24 @@ namespace Sparkles {
|
|||
}
|
||||
|
||||
|
||||
private XmlNode GetFolder (string name)
|
||||
XmlNode FolderByName (string name)
|
||||
{
|
||||
return SelectSingleNode (string.Format ("/sparkleshare/folder[name=\"{0}\"]", name));
|
||||
}
|
||||
|
||||
|
||||
private string GetFolderValue (string name, string key)
|
||||
string FolderValueByKey (string name, string key)
|
||||
{
|
||||
XmlNode folder = GetFolder(name);
|
||||
XmlNode folder = FolderByName(name);
|
||||
|
||||
if ((folder != null) && (folder [key] != null))
|
||||
return folder [key].InnerText;
|
||||
else
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void Save ()
|
||||
void Save ()
|
||||
{
|
||||
if (!File.Exists (FullPath))
|
||||
throw new FileNotFoundException (FullPath + " does not exist");
|
||||
|
|
|
@ -52,10 +52,15 @@ namespace Sparkles.Git {
|
|||
if (!RemoteUrl.Scheme.Equals ("ssh") && !RemoteUrl.Scheme.Equals ("git"))
|
||||
uri_builder.Scheme = "ssh";
|
||||
|
||||
if (RemoteUrl.Host.Equals ("github.com")) {
|
||||
if (RemoteUrl.Host.Equals ("github.com") ||
|
||||
RemoteUrl.Host.Equals ("gitlab.com")) {
|
||||
|
||||
uri_builder.Scheme = "ssh";
|
||||
uri_builder.UserName = "git";
|
||||
|
||||
if (!RemoteUrl.AbsolutePath.EndsWith (".git"))
|
||||
uri_builder.Path += ".git";
|
||||
|
||||
} else if (string.IsNullOrEmpty (RemoteUrl.UserInfo)) {
|
||||
uri_builder.UserName = "storage";
|
||||
}
|
||||
|
@ -273,6 +278,7 @@ namespace Sparkles.Git {
|
|||
git_config_clean.StartAndWaitForExit ();
|
||||
|
||||
// Pass all files through the encryption filter
|
||||
// TODO: diff=encryption merge=encryption -text?
|
||||
string git_attributes_file_path = Path.Combine (TargetFolder, ".git", "info", "attributes");
|
||||
File.WriteAllText (git_attributes_file_path, "* filter=encryption");
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Sparkles {
|
|||
if (IO.File.Exists (preset_path))
|
||||
return null;
|
||||
|
||||
// TODO: Don't write maually
|
||||
// TODO: Don't write manually
|
||||
string preset_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<sparkleshare>" +
|
||||
" <preset>" +
|
||||
|
|
3
key.text
Normal file
3
key.text
Normal file
|
@ -0,0 +1,3 @@
|
|||
gitlab.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9
|
||||
gitlab.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFSMqzJeV9rUzU4kWitGjeR4PWSa29SPqJ1fVkhtj3Hw9xjLVXVYrU9QlYWrOLXBpQ6KWjbjTDTdDkoohFzgbEY=
|
||||
gitlab.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf
|
Loading…
Reference in a new issue