agendafs

A filesystem for your calendar.

git clone git://mccd.space/agendafs
commit c53e779a18d21a498788dccf5a4d96b334ff7f51
parent ed8423a8474094d9eb6999b6695be5026deb69e8
Author: Marc Coquand <marc@coquand.email>
Date:   Mon, 14 Jul 2025 15:32:27 +0200

fix add tree root

Diffstat:
Mjournal_entry.c | 7+++++++
Mmain.c | 4++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/journal_entry.c b/journal_entry.c
@@ -427,6 +427,7 @@ load_journal_entry_from_ics_file(const char *filename,
 				 struct journal_entry *entry)
 {
 	path *filepath = append_path(ICS_DIR, filename);
+	LOG("Filepath is %s", filepath);
 
 	struct stat fileStat;
 	if (stat(filepath, &fileStat) == -1) {
@@ -558,6 +559,8 @@ load_journal_entries()
 
 			struct tree_node *parent = get_node_by_uuid(parent_uid);
 			if (parent) {
+				struct journal_entry *p_entry = parent->data;
+				LOG("Adding to parent %s", p_entry->filename);
 				detach_tree_node(child);
 				add_child(parent, child);
 			}
@@ -566,7 +569,11 @@ load_journal_entries()
 				    parent_uid);
 			}
 		}
+		else {
+			add_child(fuse_tree_root, child);
+		}
 	}
+	LOG("Inserted %zu entries", n_keys);
 
 	for (int i = 0; i < n_keys; i++) {
 		free(keys[i]);
diff --git a/main.c b/main.c
@@ -110,7 +110,10 @@ journal_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 
 	// If we are in the root directory, expose the "journal" directory
 	if (strcmp(path, "/") == 0) {
+		LOG("IS ROOT");
+
 		for (size_t i = 0; i < fuse_tree_root->child_count; i++) {
+
 			const struct tree_node *node =
 			    fuse_tree_root->children[i];
 			struct journal_entry *entry = node->data;
@@ -134,6 +137,7 @@ journal_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 		const struct tree_node *node = get_node_by_path(path);
 		if (node) {
 			for (size_t i = 0; i < node->child_count; i++) {
+				LOG("FOUND CHILD");
 				const struct tree_node *child =
 				    node->children[i];
 				struct journal_entry *entry = child->data;