controller: Generate new keys when missing. Fixes #1498
This commit is contained in:
parent
cc3d802900
commit
315252b29d
|
@ -187,6 +187,8 @@ namespace SparkleShare {
|
|||
this.lost_folders_path = true;
|
||||
}
|
||||
|
||||
bool keys_imported = false;
|
||||
|
||||
if (FirstRun) {
|
||||
Config.SetConfigOption ("notifications", bool.TrueString);
|
||||
|
||||
|
@ -208,13 +210,24 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
SparkleKeys.ImportPrivateKey (key_file_path);
|
||||
keys_imported = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CurrentUser.PublicKey = File.ReadAllText (key_file_path + ".pub");
|
||||
if (keys_imported) {
|
||||
CurrentUser.PublicKey = File.ReadAllText (key_file_path + ".pub");
|
||||
|
||||
} else {
|
||||
string [] key_pair = CreateKeys ();
|
||||
|
||||
SparkleKeys.ImportPrivateKey (key_pair [0]);
|
||||
CurrentUser.PublicKey = File.ReadAllText (key_pair [1]);
|
||||
}
|
||||
|
||||
SparkleKeys.ListPrivateKeys ();
|
||||
FolderListChanged (); // FIXME: Hacky way to update status icon menu to show the key
|
||||
}
|
||||
|
||||
// Watch the SparkleShare folder
|
||||
|
@ -261,14 +274,12 @@ namespace SparkleShare {
|
|||
if (FirstRun) {
|
||||
ShowSetupWindow (PageType.Setup);
|
||||
|
||||
new Thread (() => {
|
||||
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||
string key_file_name = DateTime.Now.ToString ("yyyy-MM-dd_HH\\hmm");
|
||||
|
||||
string [] key_pair = SparkleKeys.GenerateKeyPair (keys_path, key_file_name);
|
||||
SparkleKeys.ImportPrivateKey (key_pair [0]);
|
||||
new Thread (() => {
|
||||
string [] key_pair = CreateKeys ();
|
||||
|
||||
SparkleKeys.ImportPrivateKey (key_pair [0]);
|
||||
CurrentUser.PublicKey = File.ReadAllText (key_pair [1]);
|
||||
|
||||
FolderListChanged (); // FIXME: Hacky way to update status icon menu to show the key
|
||||
|
||||
}).Start ();
|
||||
|
@ -741,6 +752,15 @@ namespace SparkleShare {
|
|||
if (!IsSymlink (file))
|
||||
File.SetAttributes (file, FileAttributes.Normal);
|
||||
}
|
||||
|
||||
|
||||
private string [] CreateKeys ()
|
||||
{
|
||||
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||
string key_file_name = DateTime.Now.ToString ("yyyy-MM-dd_HH\\hmm");
|
||||
|
||||
return SparkleKeys.GenerateKeyPair (keys_path, key_file_name);
|
||||
}
|
||||
|
||||
|
||||
private bool IsSymlink (string file)
|
||||
|
|
Loading…
Reference in a new issue