Skip to content

Commit

Permalink
fix: Create data directory if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
paysonwallach committed Jun 24, 2021
1 parent c0828de commit cce9b9c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,18 @@ public class Caffeine.Indicator : Wingpanel.Indicator {
}

private File get_state_file () {
return File.new_build_filename (Environment.get_user_data_dir (),
Config.APP_ID, @"last-state-$(Config.DATA_VERSION)");
var data_dir = File.new_build_filename (Environment.get_user_data_dir (),
Config.APP_ID);
var state_file = data_dir.resolve_relative_path (@"last-state-$(Config.DATA_VERSION)");

if (!data_dir.query_exists ())
try {
data_dir.make_directory_with_parents ();
} catch (Error e) {
warning (e.message);
}

return state_file;
}

private void save_state () {
Expand Down

0 comments on commit cce9b9c

Please sign in to comment.