Commit 82e3caf8 authored by Jim Nelson's avatar Jim Nelson

#2532: If Shotwell can't create vital data files/directories at startup,...

#2532: If Shotwell can't create vital data files/directories at startup, instead of logging an error and exiting, it displays a dialog box error and exits.  NOTE: This introduces new translatable strings that are not the .pot file.  Although past string freeze, we feel these are very rare cases and won't be seen by 99.9% of users, but should be visible to that one-tenth of a percent that have done something really odd with their permissions.
parent 614fea20
......@@ -31,12 +31,11 @@ class AppDirs {
public static void verify_data_dir() {
File data_dir = get_data_dir();
try {
if (data_dir.query_exists(null) == false) {
if (!data_dir.make_directory_with_parents(null))
error("Unable to create data directory %s", data_dir.get_path());
}
if (!data_dir.query_exists(null))
data_dir.make_directory_with_parents(null);
} catch (Error err) {
error("%s", err.message);
AppWindow.panic(_("Unable to create data directory %s: %s").printf(data_dir.get_path(),
err.message));
}
}
......@@ -103,16 +102,12 @@ class AppDirs {
// Because multiple instances of the app can run at the same time, place temp files in
// subdir named after process ID
File tmp_dir = get_data_subdir("tmp").get_child("%d".printf((int) Posix.getpid()));
if (!tmp_dir.query_exists(null)) {
bool created = false;
try {
created = tmp_dir.make_directory_with_parents(null);
} catch (Error err) {
created = false;
}
if (!created)
error("Unable to create temporary directory %s", tmp_dir.get_path());
try {
if (!tmp_dir.query_exists(null))
tmp_dir.make_directory_with_parents(null);
} catch (Error err) {
AppWindow.panic(_("Unable to create temporary directory %s: %s").printf(
tmp_dir.get_path(), err.message));
}
return tmp_dir;
......@@ -124,12 +119,11 @@ class AppDirs {
subdir = subdir.get_child(subname);
try {
if (subdir.query_exists(null) == false) {
if (!subdir.make_directory_with_parents(null))
error("Unable to create data subdirectory %s", subdir.get_path());
}
if (!subdir.query_exists(null))
subdir.make_directory_with_parents(null);
} catch (Error err) {
error("%s", err.message);
AppWindow.panic(_("Unable to create data subdirectory %s: %s").printf(subdir.get_path(),
err.message));
}
return subdir;
......
......@@ -610,8 +610,11 @@ public abstract class AppWindow : PageWindow {
}
public static void database_error(DatabaseError err) {
string msg = _("A fatal error occurred when accessing Shotwell's library. Shotwell cannot continue.\n\n%s").printf(
err.message);
panic(_("A fatal error occurred when accessing Shotwell's library. Shotwell cannot continue.\n\n%s").printf(
err.message));
}
public static void panic(string msg) {
critical(msg);
error_message(msg);
......
......@@ -35,7 +35,8 @@ public class DatabaseTable {
int res = Sqlite.Database.open_v2(filename, out db, Sqlite.OPEN_READWRITE | Sqlite.OPEN_CREATE,
null);
if (res != Sqlite.OK)
error("Unable to open/create photo database %s: %d", filename, res);
AppWindow.panic(_("Unable to open/create photo database %s: error code %d").printf(filename,
res));
// disable synchronized commits for performance reasons ... this is not vital, hence we
// don't error out if this fails
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment