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

Proposed by Brandon Schaefer
Status: Rejected
Rejected by: Brandon Schaefer
Proposed branch: lp:~brandontschaefer/unity/lp.1328677-fix
Merge into: lp:unity
Diff against target: 62 lines (+20/-2)
3 files modified
UnityCore/DesktopUtilities.cpp (+12/-0)
UnityCore/DesktopUtilities.h (+1/-0)
plugins/unityshell/src/unityshell.cpp (+7/-2)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp.1328677-fix
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Needs Information
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+230539@code.launchpad.net

Commit message

Use CONFIG instead of CACHE to store the first_run.stamp

Description of the change

Use CONFIG instead of CACHE to store the first_run.stamp

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

Is there a way to add an "upgrade" option so that everyone isn't forced to see the Shortcuts screen again when they upgrade to this fix?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Ill just stick in a second check for the old location. After a while we can remove it I suppose. Not that big of a hit keeping that. (Also I should remove that printf).

3849. By Brandon Schaefer

* Make sure we still check ~/.cache other wise it'll cause the shortcut window to pop up on upgrades.
  * NOTE * This means, no first_run.stamp will be created if it exists in ~/.cache.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Stephen M. Webb (bregma) wrote :

If it's in XDG_CACHE_HOME, would it be possible to remove it and recreate it in XDG_CACHE_HOME, and otherwise treat it as if it were founf in XDG_CACHE_HOME? That would fix the problem permanently.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Instead of checking if both config and cache dir, why not instead adding a migration script that moves the file in cache directory (if any) to the config one, and only using config?

review: Needs Information
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Better way (from Marcos comment) here:

https://code.launchpad.net/~brandontschaefer/unity/lp.1328677-fixv2

I also had extra commits to this branch, soo easier to just make a new branch.

Unmerged revisions

3849. By Brandon Schaefer

* Make sure we still check ~/.cache other wise it'll cause the shortcut window to pop up on upgrades.
  * NOTE * This means, no first_run.stamp will be created if it exists in ~/.cache.

3848. By Brandon Schaefer

* Go to use CONFIG instead of CACHE to store the first_run.stamp

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-13 22:37:17 +0000
4@@ -66,6 +66,18 @@
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+ if (g_mkdir_with_parents(unity_config.c_str(), 0700) >= 0)
14+ return unity_config;
15+
16+ LOG_ERROR(logger) << "Impossible to create unity config folder '"<< unity_config <<"' !";
17+ return "";
18+}
19+
20 std::string DesktopUtilities::GetUserRuntimeDirectory()
21 {
22 const char *runtime_dir = g_get_user_runtime_dir();
23
24=== modified file 'UnityCore/DesktopUtilities.h'
25--- UnityCore/DesktopUtilities.h 2014-04-16 22:17:11 +0000
26+++ UnityCore/DesktopUtilities.h 2014-08-13 22:37:17 +0000
27@@ -32,6 +32,7 @@
28 static std::string GetUserDataDirectory();
29 static std::string GetUserCacheDirectory();
30 static std::string GetUserRuntimeDirectory();
31+ static std::string GetUserConfigDirectory();
32 static std::vector<std::string> GetSystemDataDirectories();
33 static std::vector<std::string> GetDataDirectories();
34
35
36=== modified file 'plugins/unityshell/src/unityshell.cpp'
37--- plugins/unityshell/src/unityshell.cpp 2014-08-11 12:30:55 +0000
38+++ plugins/unityshell/src/unityshell.cpp 2014-08-13 22:37:17 +0000
39@@ -4041,8 +4041,13 @@
40 void UnityScreen::ShowFirstRunHints()
41 {
42 sources_.AddTimeoutSeconds(1, [this] {
43+ auto const& config_dir = DesktopUtilities::GetUserConfigDirectory();
44 auto const& cache_dir = DesktopUtilities::GetUserCacheDirectory();
45- if (!cache_dir.empty() && !g_file_test((cache_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS))
46+
47+ bool is_not_in_config_dir = (!config_dir.empty() && !g_file_test((config_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS));
48+ bool is_not_in_cache_dir = (!cache_dir.empty() && !g_file_test( (cache_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS));
49+
50+ if (is_not_in_config_dir && is_not_in_cache_dir)
51 {
52 // We focus the panel, so the shortcut hint will be hidden at first user input
53 auto const& panels = panel_controller_->panels();
54@@ -4055,7 +4060,7 @@
55 shortcut_controller_->Show();
56
57 glib::Error error;
58- g_file_set_contents((cache_dir+local::FIRST_RUN_STAMP).c_str(), "", 0, &error);
59+ g_file_set_contents((config_dir+local::FIRST_RUN_STAMP).c_str(), "", 0, &error);
60
61 if (error)
62 {