summaryrefslogtreecommitdiff
path: root/src/AppDirs.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/AppDirs.vala')
-rw-r--r--src/AppDirs.vala41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 1421314..ecd375d 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -1,4 +1,4 @@
-/* Copyright 2009-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
@@ -34,13 +34,29 @@ class AppDirs {
}
public static void try_migrate_data() {
+ // Migrate the user plugin dir from .gnome2 to .local
+ File user_plugin_dir = get_user_plugins_dir();
+ File old_dir =
+ get_home_dir().get_child(".gnome2").get_child("shotwell").get_child("plugins");
+
+ if (old_dir.query_exists() && !user_plugin_dir.get_parent().query_exists()) {
+ try {
+ user_plugin_dir.get_parent().make_directory_with_parents(null);
+ } catch (Error err) { }
+ }
+
+ try {
+ old_dir.move(user_plugin_dir, FileCopyFlags.NONE);
+ } catch (Error err) { }
+
+
File new_dir = get_data_dir();
- File old_dir = get_home_dir().get_child(".shotwell");
+ old_dir = get_home_dir().get_child(".shotwell");
if (new_dir.query_exists() || !old_dir.query_exists())
return;
File cache_dir = get_cache_dir();
- Posix.mode_t mask = Posix.umask(0700);
+ Posix.mode_t mask = Posix.umask(0077);
if (!cache_dir.query_exists()) {
try {
cache_dir.make_directory_with_parents(null);
@@ -211,8 +227,23 @@ class AppDirs {
return subdir;
}
+ public static void ensure_writable(File dir) {
+ if (dir.query_exists(null)) {
+ try {
+ FileInfo info = dir.query_info(FileAttribute.UNIX_MODE, FileQueryInfoFlags.NONE);
+ uint32 mode = info.get_attribute_uint32(FileAttribute.UNIX_MODE) | 0700;
+ if (!dir.set_attribute_uint32(FileAttribute.UNIX_MODE, mode, FileQueryInfoFlags.NONE)) {
+ AppWindow.panic(_("Could not make directory %s writable").printf(dir.get_path()));
+ }
+ } catch (Error err) {
+ AppWindow.panic(_("Could not make directory %s writable: %s").printf(dir.get_path(), err.message));
+ }
+ }
+ }
+
public static File get_cache_subdir(string name, string? subname = null) {
File subdir = get_cache_dir().get_child(name);
+ ensure_writable(subdir);
if (subname != null)
subdir = subdir.get_child(subname);
@@ -223,7 +254,7 @@ class AppDirs {
AppWindow.panic(_("Unable to create data subdirectory %s: %s").printf(subdir.get_path(),
err.message));
}
-
+ ensure_writable(subdir);
return subdir;
}
@@ -246,7 +277,7 @@ class AppDirs {
}
public static File get_user_plugins_dir() {
- return get_home_dir().get_child(".gnome2").get_child("shotwell").get_child("plugins");
+ return get_data_dir().get_child("plugins");
}
public static File? get_log_file() {