agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafscommit 3c47ec5ec1bc903142f87bca201e7e9feb4057ba
parent 0e10b0e475b411592e2af657a9ed2d28c483212d
Author: Marc Coquand <marc@coquand.email>
Date: Thu, 10 Jul 2025 23:39:39 +0200
Return empty with getattr if no attr exists
Diffstat:
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/journal_entry.c b/journal_entry.c
@@ -747,7 +747,7 @@ get_node_categories(const struct tree_node *node)
{
const struct journal_entry *entry = node->data;
if (!entry) {
- return "";
+ return NULL;
}
FILE *memstream = NULL;
@@ -768,7 +768,7 @@ get_node_categories(const struct tree_node *node)
first_category) == -1) {
fclose(memstream);
free(result_buffer);
- return "";
+ return NULL;
}
catp = icalcomponent_get_next_property(
inner, ICAL_CATEGORIES_PROPERTY);
@@ -778,7 +778,7 @@ get_node_categories(const struct tree_node *node)
if (fclose(memstream) == EOF) {
free(result_buffer);
- return "";
+ return NULL;
}
return result_buffer;
@@ -953,6 +953,17 @@ write_entry_to_ical_file(const struct journal_entry *entry)
icalcomponent_set_status(entry->component, ICAL_STATUS_FINAL);
+ const char *descr_prop =
+ icalcomponent_get_description(entry->component);
+ if (descr_prop != NULL && strcmp("", descr_prop) == 0) {
+ icalproperty *ical_descr_prop =
+ icalcomponent_get_first_property(
+ icalcomponent_get_inner(entry->component),
+ ICAL_DESCRIPTION_PROPERTY);
+ icalcomponent_remove_property(
+ icalcomponent_get_inner(entry->component), ical_descr_prop);
+ }
+
LOG("Set last modified");
char *ical_str = icalcomponent_as_ical_string_r(entry->component);
diff --git a/main.c b/main.c
@@ -479,6 +479,10 @@ journal_getxattr(const char *path, const char *header, char *buf, size_t s)
const char *cats = get_node_categories(node);
pthread_mutex_unlock(&entries_mutex);
+ if (!cats || *cats == '\0') {
+ return -ENODATA;
+ }
+
int string_len = strlen(cats);
// If s == 0 we don't need to write, just return size to
@@ -500,6 +504,9 @@ journal_getxattr(const char *path, const char *header, char *buf, size_t s)
const char *c = get_node_class(node);
pthread_mutex_unlock(&entries_mutex);
+ if (!c || *c == '\0') {
+ return -ENODATA;
+ }
int string_len = strlen(c);