Skip to content

Commit

Permalink
always have an config object (#371)
Browse files Browse the repository at this point in the history
Fixes: #370
  • Loading branch information
ygerlach authored Dec 2, 2024
1 parent 06a6a14 commit 85c6561
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Core/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3202,7 +3202,7 @@ public class Main : GLib.Object{
else{
// retain values for next run
config.set_string_member("backup_device_uuid", backup_uuid);
config.set_string_member("parent_device_uuid", backup_parent_uuid);
config.set_string_member("parent_device_uuid", backup_parent_uuid);
}

config.set_string_member("do_first_run", false.to_string());
Expand Down Expand Up @@ -3298,8 +3298,10 @@ public class Main : GLib.Object{
} catch (Error e) {
log_error (e.message);
}
var node = parser.get_root();
var config = node.get_object();
Json.Node? node = parser.get_root();

// make sure object is always set
Json.Object config = node?.get_object() ?? new Json.Object();

bool do_first_run = json_get_bool(config, "do_first_run", false); // false as default

Expand All @@ -3308,7 +3310,7 @@ public class Main : GLib.Object{
if (do_first_run){
set_first_run_flag();
}

if (config.has_member("include_btrfs_home")){
include_btrfs_home_for_backup = json_get_bool(config, "include_btrfs_home", include_btrfs_home_for_backup);
}
Expand All @@ -3325,7 +3327,7 @@ public class Main : GLib.Object{

backup_uuid = json_get_string(config,"backup_device_uuid", backup_uuid);
backup_parent_uuid = json_get_string(config,"parent_device_uuid", backup_parent_uuid);

this.schedule_monthly = json_get_bool(config,"schedule_monthly",schedule_monthly);
this.schedule_weekly = json_get_bool(config,"schedule_weekly",schedule_weekly);
this.schedule_daily = json_get_bool(config,"schedule_daily",schedule_daily);
Expand Down

0 comments on commit 85c6561

Please sign in to comment.