Merge lp:~brandontschaefer/unity/lp.1328677-fixv2 into lp:unity

Proposed by Brandon Schaefer on 2014-08-26
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2014-08-27
Approved revision: 3862
Merged at revision: 3868
Proposed branch: lp:~brandontschaefer/unity/lp.1328677-fixv2
Merge into: lp:unity
Diff against target: 108 lines (+54/-3)
5 files modified
UnityCore/DesktopUtilities.cpp (+14/-0)
UnityCore/DesktopUtilities.h (+1/-0)
debian/unity.migrations (+1/-0)
plugins/unityshell/src/unityshell.cpp (+3/-3)
tools/migration-scripts/03_unity_first_run_stamp_move (+35/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp.1328677-fixv2
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2014-08-26 Approve on 2014-08-27
PS Jenkins bot (community) continuous-integration Approve on 2014-08-27
Review via email: mp+232336@code.launchpad.net

Commit message

Use CONFIG instead of CACHE to store the first_run.stamp

Create a migration script to move the new stamp to the new location

Description of the change

Use CONFIG instead of CACHE to store the first_run.stamp

Create a migration script to move the new stamp to the new location

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Marco Trevisan (Treviño) (3v1n0) wrote :

Cool, looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/DesktopUtilities.cpp'
2--- UnityCore/DesktopUtilities.cpp 2014-04-16 22:17:11 +0000
3+++ UnityCore/DesktopUtilities.cpp 2014-08-26 23:30:51 +0000
4@@ -66,6 +66,20 @@
5 return "";
6 }
7
8+std::string DesktopUtilities::GetUserConfigDirectory()
9+{
10+ const char *config_dir = g_get_user_config_dir();
11+ auto unity_config = glib::gchar_to_string(config_dir).append(G_DIR_SEPARATOR_S "unity" G_DIR_SEPARATOR_S);
12+
13+ printf("CONFIG %s\n", unity_config.c_str());
14+
15+ if (g_mkdir_with_parents(unity_config.c_str(), 0700) >= 0)
16+ return unity_config;
17+
18+ LOG_ERROR(logger) << "Impossible to create unity config folder '"<< unity_config <<"' !";
19+ return "";
20+}
21+
22 std::string DesktopUtilities::GetUserRuntimeDirectory()
23 {
24 const char *runtime_dir = g_get_user_runtime_dir();
25
26=== modified file 'UnityCore/DesktopUtilities.h'
27--- UnityCore/DesktopUtilities.h 2014-04-16 22:17:11 +0000
28+++ UnityCore/DesktopUtilities.h 2014-08-26 23:30:51 +0000
29@@ -32,6 +32,7 @@
30 static std::string GetUserDataDirectory();
31 static std::string GetUserCacheDirectory();
32 static std::string GetUserRuntimeDirectory();
33+ static std::string GetUserConfigDirectory();
34 static std::vector<std::string> GetSystemDataDirectories();
35 static std::vector<std::string> GetDataDirectories();
36
37
38=== modified file 'debian/unity.migrations'
39--- debian/unity.migrations 2014-03-21 02:58:13 +0000
40+++ debian/unity.migrations 2014-08-26 23:30:51 +0000
41@@ -1,2 +1,3 @@
42 tools/migration-scripts/01_unity_change_dconf_path
43 tools/migration-scripts/02_unity_setup_text_scale_factor
44+tools/migration-scripts/03_unity_first_run_stamp_move
45
46=== modified file 'plugins/unityshell/src/unityshell.cpp'
47--- plugins/unityshell/src/unityshell.cpp 2014-08-11 12:30:55 +0000
48+++ plugins/unityshell/src/unityshell.cpp 2014-08-26 23:30:51 +0000
49@@ -4041,8 +4041,8 @@
50 void UnityScreen::ShowFirstRunHints()
51 {
52 sources_.AddTimeoutSeconds(1, [this] {
53- auto const& cache_dir = DesktopUtilities::GetUserCacheDirectory();
54- if (!cache_dir.empty() && !g_file_test((cache_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS))
55+ auto const& config_dir = DesktopUtilities::GetUserConfigDirectory();
56+ if (!config_dir.empty() && !g_file_test((config_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS))
57 {
58 // We focus the panel, so the shortcut hint will be hidden at first user input
59 auto const& panels = panel_controller_->panels();
60@@ -4055,7 +4055,7 @@
61 shortcut_controller_->Show();
62
63 glib::Error error;
64- g_file_set_contents((cache_dir+local::FIRST_RUN_STAMP).c_str(), "", 0, &error);
65+ g_file_set_contents((config_dir+local::FIRST_RUN_STAMP).c_str(), "", 0, &error);
66
67 if (error)
68 {
69
70=== added file 'tools/migration-scripts/03_unity_first_run_stamp_move'
71--- tools/migration-scripts/03_unity_first_run_stamp_move 1970-01-01 00:00:00 +0000
72+++ tools/migration-scripts/03_unity_first_run_stamp_move 2014-08-26 23:30:51 +0000
73@@ -0,0 +1,35 @@
74+#!/usr/bin/python
75+# -*- coding: utf-8 -*-
76+# Copyright (C) 2014 Canonical
77+#
78+# Authors:
79+# Brandon Schaefer <brandon.schaefer@canonical.com>
80+#
81+# This program is free software; you can redistribute it and/or modify it under
82+# the terms of the GNU General Public License as published by the Free Software
83+# Foundation; version 3.
84+#
85+# This program is distributed in the hope that it will be useful, but WITHOUTa
86+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
87+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
88+# details.
89+#
90+# You should have received a copy of the GNU General Public License along with
91+# this program; if not, write to the Free Software Foundation, Inc.,
92+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
93+
94+from gi.repository import GLib
95+from os import path, rename, mkdir
96+
97+old_first_run_path = GLib.get_user_cache_dir() + "/unity/first_run.stamp"
98+new_first_run_path = GLib.get_user_config_dir() + "/unity"
99+
100+# If we have the old first_run.stamp file, we must move it to the new location
101+if path.isfile(old_first_run_path):
102+
103+ # make sure the new dir exists before attempting to move
104+ if not path.isdir(new_first_run_path):
105+ mkdir(new_first_run_path)
106+
107+ new_first_run_path += "/first_run.stamp"
108+ rename(old_first_run_path, new_first_run_path)