Fix some events not firing and deleting of temporary repos
This commit is contained in:
parent
83c39669d7
commit
b3d7a2bd2e
|
@ -33,13 +33,11 @@ namespace SparkleShare {
|
|||
|
||||
private string Folder;
|
||||
private string RemoteOriginUrl;
|
||||
private string RepoName;
|
||||
|
||||
|
||||
public SparkleFetcher (string url, string folder)
|
||||
{
|
||||
|
||||
RepoName = Path.GetDirectoryName (folder);
|
||||
Folder = folder;
|
||||
RemoteOriginUrl = url;
|
||||
|
||||
|
@ -81,16 +79,13 @@ namespace SparkleShare {
|
|||
|
||||
} else {
|
||||
|
||||
InstallUserInfo ();
|
||||
InstallExcludeRules ();
|
||||
|
||||
args = new SparkleEventArgs ("CloningFinished");
|
||||
|
||||
Console.WriteLine ("FINISHED");
|
||||
|
||||
if (CloningFinished != null) {
|
||||
Console.WriteLine ("EVENT FIRED");
|
||||
if (CloningFinished != null)
|
||||
CloningFinished (this, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,13 +96,19 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
private void InstallUserInfo ()
|
||||
{
|
||||
|
||||
// Install username and email from global file
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Add a .gitignore file to the repo
|
||||
private void InstallExcludeRules ()
|
||||
{
|
||||
|
||||
TextWriter writer;
|
||||
writer = new StreamWriter (SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||
RepoName, ".git/info/exclude"));
|
||||
TextWriter writer = new StreamWriter (SparkleHelpers.CombineMore (Folder, ".git/info/exclude"));
|
||||
|
||||
writer.WriteLine ("*~"); // Ignore gedit swap files
|
||||
writer.WriteLine (".*.sw?"); // Ignore vi swap files
|
||||
|
|
|
@ -334,7 +334,8 @@ namespace SparkleShare {
|
|||
|
||||
|
||||
string url = server + "/" + name;
|
||||
string tmp_folder = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, name);
|
||||
string tmp_folder = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath,
|
||||
System.IO.Path.GetFileNameWithoutExtension (name));
|
||||
|
||||
SparkleFetcher fetcher = new SparkleFetcher (url, tmp_folder);
|
||||
|
||||
|
@ -349,14 +350,11 @@ namespace SparkleShare {
|
|||
|
||||
fetcher.CloningFinished += delegate {
|
||||
|
||||
Console.WriteLine ("CLONING FINISHED");
|
||||
|
||||
SparkleHelpers.DebugInfo ("Git", "[" + name + "] Repository cloned");
|
||||
|
||||
Directory.Move (tmp_folder,
|
||||
SparkleHelpers.CombineMore (SparklePaths.SparklePath, name));
|
||||
ClearAttributes (tmp_folder);
|
||||
|
||||
// Install username and email from global file
|
||||
Directory.Move (tmp_folder, SparklePaths.SparklePath);
|
||||
|
||||
ShowFinishedStep ();
|
||||
|
||||
|
@ -367,20 +365,18 @@ namespace SparkleShare {
|
|||
|
||||
SparkleHelpers.DebugInfo ("Git", "[" + name + "] Cloning failed");
|
||||
|
||||
try {
|
||||
if (Directory.Exists (tmp_folder)) {
|
||||
|
||||
Directory.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath,
|
||||
name));
|
||||
ClearAttributes (tmp_folder);
|
||||
Directory.Delete (tmp_folder, true);
|
||||
|
||||
SparkleHelpers.DebugInfo ("Config",
|
||||
"[" + name + "] Deleted temporary directory");
|
||||
|
||||
} catch (System.IO.DirectoryNotFoundException) {
|
||||
}
|
||||
|
||||
ShowErrorStep ();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ShowStepTwoAndAHalf ();
|
||||
|
@ -420,6 +416,27 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
// Recursively sets access rights of a folder to 'Normal'
|
||||
private void ClearAttributes (string path)
|
||||
{
|
||||
|
||||
if (Directory .Exists (path)) {
|
||||
|
||||
string [] folders = Directory .GetDirectories (path);
|
||||
|
||||
foreach (string folder in folders)
|
||||
ClearAttributes (folder);
|
||||
|
||||
string [] files = Directory .GetFiles(path);
|
||||
|
||||
foreach (string file in files)
|
||||
File.SetAttributes (file, FileAttributes.Normal);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ShowErrorStep ()
|
||||
{
|
||||
|
||||
|
@ -440,7 +457,7 @@ namespace SparkleShare {
|
|||
|
||||
Label header = new Label ("<span size='x-large'><b>" +
|
||||
_("Something went wrong…") +
|
||||
"</b></span>") {
|
||||
"</b></span>\n") {
|
||||
UseMarkup = true,
|
||||
Xalign = 0
|
||||
};
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="SparkleBubble.cs" />
|
||||
<Compile Include="SparkleFetcher.cs" />
|
||||
<Compile Include="SparkleIntro.cs" />
|
||||
<Compile Include="SparkleHelpers.cs" />
|
||||
<Compile Include="SparklePaths.cs" />
|
||||
|
|
Loading…
Reference in a new issue