From 9fbe8a8add74babecc6d255d34c391f2e2e52aa0 Mon Sep 17 00:00:00 2001
From: KJ Lawrence
Date: Tue, 12 Jun 2018 23:54:29 -0400
Subject: [PATCH] Use "mv" to move directories
- Also added in some basic error logging
- Version update
- Fix date
---
README.md | 2 +-
data/com.github.kjlaw89.archetype.appdata.xml | 5 +++
debian/changelog | 6 +++
src/controllers/AppController.vala | 12 ++++++
src/models/Template.vala | 43 ++++++++++---------
src/views/AppView.vala | 6 ++-
6 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/README.md b/README.md
index 7bab8dc..05b4541 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
-
+
diff --git a/data/com.github.kjlaw89.archetype.appdata.xml b/data/com.github.kjlaw89.archetype.appdata.xml
index ea2f55a..c96773a 100644
--- a/data/com.github.kjlaw89.archetype.appdata.xml
+++ b/data/com.github.kjlaw89.archetype.appdata.xml
@@ -32,6 +32,11 @@
+
+
+ Changed method for moving temp directory and added in basic error logging
+
+
Updated description and colors
diff --git a/debian/changelog b/debian/changelog
index 6940465..b239e55 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+com.github.kjlaw89.archetype (1.0.2) xenial; urgency=low
+
+ * Update to fix moving temp directory and basic error logging
+
+ -- KJ Lawrence Tue, 12 Jun 2018 23:45:00 -0500
+
com.github.kjlaw89.archetype (1.0.0) xenial; urgency=low
* Initial Release
diff --git a/src/controllers/AppController.vala b/src/controllers/AppController.vala
index 9c1c13c..5ff22d6 100644
--- a/src/controllers/AppController.vala
+++ b/src/controllers/AppController.vala
@@ -75,7 +75,19 @@ namespace App.Controllers {
var directory = File.new_for_path (template.directory);
Granite.Services.System.open (directory);
quit ();
+ return;
}
+
+ this.app_view.error_label.label = "Unable to create project";
+ var dialog = new Granite.MessageDialog.with_image_from_icon_name (
+ "Unable to create project",
+ template.error,
+ "dialog-error",
+ Gtk.ButtonsType.CLOSE
+ );
+
+ dialog.run ();
+ dialog.destroy ();
}
}
}
diff --git a/src/models/Template.vala b/src/models/Template.vala
index 3ec4431..0fdadb3 100644
--- a/src/models/Template.vala
+++ b/src/models/Template.vala
@@ -25,6 +25,7 @@ namespace App.Models {
public class Template {
private App.Views.AppView view;
+ public string error { get; private set; default = ""; }
public string author { get; set; }
public string author_email { get; set; }
@@ -104,7 +105,8 @@ namespace App.Models {
return true;
}
catch (Error e) {
- warning ("Unable to delete temporary files " + export_path +", "+ tar_path);
+ error = "Unable to delete temporary files " + export_path +", "+ tar_path;
+ warning (error);
}
return false;
@@ -123,12 +125,14 @@ namespace App.Models {
// Attempt to load the template resource
try {
if (!template_file.load_contents (null, out data, null)) {
- warning ("Unable to load template resource");
+ error = "Unable to load template resource";
+ warning (error);
return false;
}
}
catch (Error e) {
- warning ("Unable to load resource " + e.message);
+ error = "Unable to load resource " + e.message;
+ warning (error);
return false;
}
@@ -140,7 +144,8 @@ namespace App.Models {
output.write_all (data, null);
}
catch (Error e) {
- warning ("Unable to create archive in /tmp " + e.message);
+ error = "Unable to create archive in /tmp " + e.message;
+ warning (error);
return false;
}
@@ -150,7 +155,8 @@ namespace App.Models {
Process.spawn_command_line_sync ("tar -xzf "+ tar_path +" -C "+ export_path);
}
catch (Error e) {
- warning ("Unable to unzip archive in /tmp " + e.message);
+ error = "Unable to unzip archive in /tmp " + e.message;
+ warning (error);
return false;
}
@@ -223,12 +229,14 @@ namespace App.Models {
try {
if (!license_preamble_file.load_contents (null, out license_preamble_data, null)) {
- warning ("Unable to load license preamble resource");
+ error = "Unable to load license preamble resource";
+ warning (error);
return false;
}
}
catch (Error e) {
- warning ("Unable to get license preamble " + e.message);
+ error = "Unable to get license preamble " + e.message;
+ warning (error);
return false;
}
@@ -272,23 +280,16 @@ namespace App.Models {
initialize_git (export_path);
}
- // Move directory
- var source_dir = File.new_for_path (export_path);
- var dest_dir = File.new_for_path (directory);
+ // Move directory
+ string stdout;
+ string stderr;
+ Process.spawn_command_line_sync ("mv \""+ export_path +"\" \""+ directory + "\"", out stdout, out stderr);
- try {
- if (!source_dir.move (dest_dir, FileCopyFlags.NONE)) {
- warning ("Unable to move temp directory to " + directory);
- clean (rdnn);
- return false;
- }
- }
- catch (Error e) {
- warning ("Unable to move temp directory to "+ directory +" - "+ e.message);
- clean (rdnn);
+ if (stderr.length > 0) {
+ error = "Unable to move temp directory to "+ directory +" - "+ stderr;
+ warning (error);
return false;
}
-
// Clean up after the build process (only the .tar.gz should be left)
clean (rdnn);
diff --git a/src/views/AppView.vala b/src/views/AppView.vala
index 6c1b33e..9be2d21 100644
--- a/src/views/AppView.vala
+++ b/src/views/AppView.vala
@@ -55,6 +55,7 @@ namespace App.Views {
public Gtk.FileChooserButton directory_button { get; private set; }
public Gtk.Label directory_executable_label { get; private set; }
public Gtk.Entry domain_entry { get; private set; }
+ public Gtk.Label error_label { get; private set; }
public Gtk.Entry exec_entry { get; private set; }
public Gtk.Label executable_label { get; private set; }
public Gtk.Button generate_button { get; private set; }
@@ -134,6 +135,9 @@ namespace App.Views {
back ();
});
+ error_label = new Gtk.Label (null);
+ error_label.get_style_context ().add_class ("error");
+
var action_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
action_buttons_box.halign = Gtk.Align.END;
action_buttons_box.add (back_button);
@@ -143,11 +147,11 @@ namespace App.Views {
var buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
buttons_box.hexpand = true;
buttons_box.margin_top = 24;
+ buttons_box.add (error_label);
buttons_box.add (action_buttons_box);
this.add (stack_view);
this.add (buttons_box);
-
stage = "project";
toggle_buttons ();