keys: don't be anal about key file names and use all available keys
This commit is contained in:
parent
286cb5dcb6
commit
8ca3bd3b6b
|
@ -201,21 +201,16 @@ namespace SparkleShare {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
string keys_path = Path.GetDirectoryName (this.config.FullPath);
|
string keys_path = Path.GetDirectoryName (this.config.FullPath);
|
||||||
string key_file_name = "sparkleshare." + CurrentUser.Email + ".key";
|
string key_file_path = "";
|
||||||
string key_file_path = Path.Combine (keys_path, key_file_name);
|
|
||||||
|
|
||||||
// Be forgiving about the key's file name
|
|
||||||
if (!File.Exists (key_file_path)) {
|
|
||||||
foreach (string file_name in Directory.GetFiles (keys_path)) {
|
foreach (string file_name in Directory.GetFiles (keys_path)) {
|
||||||
if (file_name.StartsWith ("sparkleshare") &&
|
if (file_name.EndsWith (".key")) {
|
||||||
file_name.EndsWith (".key")) {
|
|
||||||
|
|
||||||
key_file_path = Path.Combine (keys_path, file_name);
|
key_file_path = Path.Combine (keys_path, file_name);
|
||||||
break;
|
SparkleKeys.ImportPrivateKey (key_file_path);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty (key_file_path)) {
|
||||||
string pubkey_file_path = key_file_path + ".pub";
|
string pubkey_file_path = key_file_path + ".pub";
|
||||||
string link_code_file_path = Path.Combine (FoldersPath, CurrentUser.Name + "'s link code.txt");
|
string link_code_file_path = Path.Combine (FoldersPath, CurrentUser.Name + "'s link code.txt");
|
||||||
|
|
||||||
|
@ -224,7 +219,8 @@ namespace SparkleShare {
|
||||||
if (File.Exists (pubkey_file_path) && !File.Exists (link_code_file_path))
|
if (File.Exists (pubkey_file_path) && !File.Exists (link_code_file_path))
|
||||||
File.Copy (pubkey_file_path, link_code_file_path, true /* Overwriting allowed */ );
|
File.Copy (pubkey_file_path, link_code_file_path, true /* Overwriting allowed */ );
|
||||||
|
|
||||||
SparkleKeys.ImportPrivateKey (key_file_path);
|
}
|
||||||
|
|
||||||
SparkleKeys.ListPrivateKeys ();
|
SparkleKeys.ListPrivateKeys ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,10 +281,9 @@ namespace SparkleShare {
|
||||||
{
|
{
|
||||||
Program.Controller.CurrentUser = new SparkleUser (full_name, email);
|
Program.Controller.CurrentUser = new SparkleUser (full_name, email);
|
||||||
|
|
||||||
new Thread (
|
new Thread (() => {
|
||||||
new ThreadStart (delegate {
|
|
||||||
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||||
string key_file_name = "sparkleshare." + Program.Controller.CurrentUser.Email;
|
string key_file_name = DateTime.Now.ToString ("YYYY-MM-dd HH\\hmm");
|
||||||
|
|
||||||
string [] key_pair = SparkleKeys.GenerateKeyPair (keys_path, key_file_name);
|
string [] key_pair = SparkleKeys.GenerateKeyPair (keys_path, key_file_name);
|
||||||
SparkleKeys.ImportPrivateKey (key_pair [0]);
|
SparkleKeys.ImportPrivateKey (key_pair [0]);
|
||||||
|
@ -295,8 +294,8 @@ namespace SparkleShare {
|
||||||
// Create an easily accessible copy of the public
|
// Create an easily accessible copy of the public
|
||||||
// key in the user's SparkleShare folder
|
// key in the user's SparkleShare folder
|
||||||
File.Copy (key_pair [1], link_code_file_path, true);
|
File.Copy (key_pair [1], link_code_file_path, true);
|
||||||
})
|
|
||||||
).Start ();
|
}).Start ();
|
||||||
|
|
||||||
TutorialPageNumber = 1;
|
TutorialPageNumber = 1;
|
||||||
|
|
||||||
|
@ -421,12 +420,11 @@ namespace SparkleShare {
|
||||||
Program.Controller.FolderFetchError += AddPageFetchErrorDelegate;
|
Program.Controller.FolderFetchError += AddPageFetchErrorDelegate;
|
||||||
Program.Controller.FolderFetching += SyncingPageFetchingDelegate;
|
Program.Controller.FolderFetching += SyncingPageFetchingDelegate;
|
||||||
|
|
||||||
new Thread (
|
new Thread (() => {
|
||||||
new ThreadStart (delegate {
|
|
||||||
Program.Controller.StartFetcher (address, SelectedPlugin.Fingerprint, remote_path,
|
Program.Controller.StartFetcher (address, SelectedPlugin.Fingerprint, remote_path,
|
||||||
SelectedPlugin.AnnouncementsUrl, this.fetch_prior_history);
|
SelectedPlugin.AnnouncementsUrl, this.fetch_prior_history);
|
||||||
})
|
|
||||||
).Start ();
|
}).Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following private methods are
|
// The following private methods are
|
||||||
|
@ -602,12 +600,11 @@ namespace SparkleShare {
|
||||||
if (ChangePageEvent != null)
|
if (ChangePageEvent != null)
|
||||||
ChangePageEvent (PageType.Syncing, null);
|
ChangePageEvent (PageType.Syncing, null);
|
||||||
|
|
||||||
new Thread (
|
new Thread (() => {
|
||||||
new ThreadStart (delegate {
|
|
||||||
Thread.Sleep (1000);
|
Thread.Sleep (1000);
|
||||||
Program.Controller.FinishFetcher (password);
|
Program.Controller.FinishFetcher (password);
|
||||||
})
|
|
||||||
).Start ();
|
}).Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -254,11 +254,10 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void OpenRecentEventsClicked ()
|
public void OpenRecentEventsClicked ()
|
||||||
{
|
{
|
||||||
new Threading.Thread (
|
new Threading.Thread (() => {
|
||||||
new Threading.ThreadStart (delegate {
|
|
||||||
Program.Controller.ShowEventLogWindow ();
|
Program.Controller.ShowEventLogWindow ();
|
||||||
})
|
|
||||||
).Start ();
|
}).Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue