From cce9b9ce4c45ee56bd080649e11ca5943092787e Mon Sep 17 00:00:00 2001 From: Payson Wallach Date: Thu, 24 Jun 2021 22:12:11 +0200 Subject: [PATCH] fix: Create data directory if it does not exist --- src/Indicator.vala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Indicator.vala b/src/Indicator.vala index e6d7c5f..2b2f922 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -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 () {