agendafs

A filesystem for your calendar.

git clone git://mccd.space/agendafs
commit 0f4a7a834df3ac67f623a4e341b4677f11a6d971
parent 6f6775e865f06ed44a1e95db7c135a13f57020b1
Author: Marc Coquand <marc@coquand.email>
Date:   Mon, 14 Jul 2025 16:02:08 +0200

Add write errors

Diffstat:
Mjournal_entry.c | 31++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/journal_entry.c b/journal_entry.c
@@ -165,14 +165,14 @@ remove_parent_child_relationship_from_component(icalcomponent *parent,
 	}
 }
 
-void
+int
 add_child_to_node(struct tree_node *parent, struct tree_node *child)
 {
 	// Root node, don't add relationship to component
 	if (is_root_node(parent)) {
 		LOG("Is root node, not adding relationship");
 		add_child(parent, child);
-		return;
+		return 0;
 	}
 	else {
 		LOG("Adding parent and child relation");
@@ -180,10 +180,14 @@ add_child_to_node(struct tree_node *parent, struct tree_node *child)
 		struct journal_entry *c_entry = child->data;
 		set_parent_child_relationship_to_component(p_entry->component,
 							   c_entry->component);
-		write_entry_to_ical_file(p_entry);
-		write_entry_to_ical_file(c_entry);
+		if (write_entry_to_ical_file(p_entry) != 0) {
+			return -EIO;
+		}
+		if (write_entry_to_ical_file(c_entry) != 0) {
+			return -EIO;
+		}
 
-		add_child(parent, child);
+		return add_child(parent, child);
 	}
 }
 
@@ -403,7 +407,7 @@ parse_ics_to_journal_entry_component(const char *filename,
 	return 0;
 }
 
-void
+int
 move_node(struct tree_node *old_parent, struct tree_node *new_parent,
 	  struct tree_node *child)
 {
@@ -418,7 +422,7 @@ move_node(struct tree_node *old_parent, struct tree_node *new_parent,
 		write_entry_to_ical_file(old_parent_entry);
 	}
 	detach_tree_node(child);
-	add_child_to_node(new_parent, child);
+	return add_child_to_node(new_parent, child);
 }
 
 // Returns -1 on failure, 0 on success
@@ -698,10 +702,8 @@ get_node_categories(const struct tree_node *node)
 		first_category = false;
 	}
 
-	if (fclose(memstream) == EOF) {
-		free(result_buffer);
-		return NULL;
-	}
+	size_t res = fclose(memstream);
+	assert(res != EOF);
 
 	return result_buffer;
 }
@@ -1107,10 +1109,13 @@ create_entry_from_fuse(const char *fuse_path)
 	}
 	if (!node_is_directory(parent)) {
 		LOG("Parent is not directory ");
-
 		return -ENOTDIR;
 	}
-	add_child_to_node(parent, new_node);
+
+	if (add_child_to_node(parent, new_node) != 0) {
+		return -EIO;
+	}
+
 	hashmap_insert(entries_original_ics, new_entry->filename_original,
 		       new_node);