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

Proposed by Brandon Schaefer
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
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) Approve
PS Jenkins bot (community) continuous-integration Approve
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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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
=== modified file 'UnityCore/DesktopUtilities.cpp'
--- UnityCore/DesktopUtilities.cpp 2014-04-16 22:17:11 +0000
+++ UnityCore/DesktopUtilities.cpp 2014-08-26 23:30:51 +0000
@@ -66,6 +66,20 @@
66 return "";66 return "";
67}67}
6868
69std::string DesktopUtilities::GetUserConfigDirectory()
70{
71 const char *config_dir = g_get_user_config_dir();
72 auto unity_config = glib::gchar_to_string(config_dir).append(G_DIR_SEPARATOR_S "unity" G_DIR_SEPARATOR_S);
73
74 printf("CONFIG %s\n", unity_config.c_str());
75
76 if (g_mkdir_with_parents(unity_config.c_str(), 0700) >= 0)
77 return unity_config;
78
79 LOG_ERROR(logger) << "Impossible to create unity config folder '"<< unity_config <<"' !";
80 return "";
81}
82
69std::string DesktopUtilities::GetUserRuntimeDirectory()83std::string DesktopUtilities::GetUserRuntimeDirectory()
70{84{
71 const char *runtime_dir = g_get_user_runtime_dir();85 const char *runtime_dir = g_get_user_runtime_dir();
7286
=== modified file 'UnityCore/DesktopUtilities.h'
--- UnityCore/DesktopUtilities.h 2014-04-16 22:17:11 +0000
+++ UnityCore/DesktopUtilities.h 2014-08-26 23:30:51 +0000
@@ -32,6 +32,7 @@
32 static std::string GetUserDataDirectory();32 static std::string GetUserDataDirectory();
33 static std::string GetUserCacheDirectory();33 static std::string GetUserCacheDirectory();
34 static std::string GetUserRuntimeDirectory();34 static std::string GetUserRuntimeDirectory();
35 static std::string GetUserConfigDirectory();
35 static std::vector<std::string> GetSystemDataDirectories();36 static std::vector<std::string> GetSystemDataDirectories();
36 static std::vector<std::string> GetDataDirectories();37 static std::vector<std::string> GetDataDirectories();
3738
3839
=== modified file 'debian/unity.migrations'
--- debian/unity.migrations 2014-03-21 02:58:13 +0000
+++ debian/unity.migrations 2014-08-26 23:30:51 +0000
@@ -1,2 +1,3 @@
1tools/migration-scripts/01_unity_change_dconf_path1tools/migration-scripts/01_unity_change_dconf_path
2tools/migration-scripts/02_unity_setup_text_scale_factor2tools/migration-scripts/02_unity_setup_text_scale_factor
3tools/migration-scripts/03_unity_first_run_stamp_move
34
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2014-08-11 12:30:55 +0000
+++ plugins/unityshell/src/unityshell.cpp 2014-08-26 23:30:51 +0000
@@ -4041,8 +4041,8 @@
4041void UnityScreen::ShowFirstRunHints()4041void UnityScreen::ShowFirstRunHints()
4042{4042{
4043 sources_.AddTimeoutSeconds(1, [this] {4043 sources_.AddTimeoutSeconds(1, [this] {
4044 auto const& cache_dir = DesktopUtilities::GetUserCacheDirectory();4044 auto const& config_dir = DesktopUtilities::GetUserConfigDirectory();
4045 if (!cache_dir.empty() && !g_file_test((cache_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS))4045 if (!config_dir.empty() && !g_file_test((config_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS))
4046 {4046 {
4047 // We focus the panel, so the shortcut hint will be hidden at first user input4047 // We focus the panel, so the shortcut hint will be hidden at first user input
4048 auto const& panels = panel_controller_->panels();4048 auto const& panels = panel_controller_->panels();
@@ -4055,7 +4055,7 @@
4055 shortcut_controller_->Show();4055 shortcut_controller_->Show();
40564056
4057 glib::Error error;4057 glib::Error error;
4058 g_file_set_contents((cache_dir+local::FIRST_RUN_STAMP).c_str(), "", 0, &error);4058 g_file_set_contents((config_dir+local::FIRST_RUN_STAMP).c_str(), "", 0, &error);
40594059
4060 if (error)4060 if (error)
4061 {4061 {
40624062
=== added file 'tools/migration-scripts/03_unity_first_run_stamp_move'
--- tools/migration-scripts/03_unity_first_run_stamp_move 1970-01-01 00:00:00 +0000
+++ tools/migration-scripts/03_unity_first_run_stamp_move 2014-08-26 23:30:51 +0000
@@ -0,0 +1,35 @@
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3# Copyright (C) 2014 Canonical
4#
5# Authors:
6# Brandon Schaefer <brandon.schaefer@canonical.com>
7#
8# This program is free software; you can redistribute it and/or modify it under
9# the terms of the GNU General Public License as published by the Free Software
10# Foundation; version 3.
11#
12# This program is distributed in the hope that it will be useful, but WITHOUTa
13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15# details.
16#
17# You should have received a copy of the GNU General Public License along with
18# this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21from gi.repository import GLib
22from os import path, rename, mkdir
23
24old_first_run_path = GLib.get_user_cache_dir() + "/unity/first_run.stamp"
25new_first_run_path = GLib.get_user_config_dir() + "/unity"
26
27# If we have the old first_run.stamp file, we must move it to the new location
28if path.isfile(old_first_run_path):
29
30 # make sure the new dir exists before attempting to move
31 if not path.isdir(new_first_run_path):
32 mkdir(new_first_run_path)
33
34 new_first_run_path += "/first_run.stamp"
35 rename(old_first_run_path, new_first_run_path)