From fe9acea94b289da6d83d6727a3ea0682250e8175 Mon Sep 17 00:00:00 2001 From: Carl Niklas Rydberg Date: Sun, 21 Dec 2025 22:49:24 +0100 Subject: [PATCH] Updated amduat_asl_store_fs_put_impl so fsync failure cleanup only unlinks when this call actually created the object, preventing deletion of pre-existing mappings. Change is in asl_store_fs.c. --- src/adapters/asl_store_fs/asl_store_fs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/adapters/asl_store_fs/asl_store_fs.c b/src/adapters/asl_store_fs/asl_store_fs.c index 9916722..75f71b7 100644 --- a/src/adapters/asl_store_fs/asl_store_fs.c +++ b/src/adapters/asl_store_fs/asl_store_fs.c @@ -312,6 +312,7 @@ static amduat_asl_store_error_t amduat_asl_store_fs_put_impl( char *object_path; amduat_asl_store_error_t cmp_err; amduat_asl_store_fs_write_status_t write_status; + bool wrote_new; if (ctx == NULL || out_ref == NULL) { return AMDUAT_ASL_STORE_ERR_INTEGRITY; @@ -407,6 +408,7 @@ static amduat_asl_store_error_t amduat_asl_store_fs_put_impl( return cmp_err; } + wrote_new = false; write_status = amduat_asl_store_fs_write_atomic(level2_path, object_path, artifact_bytes.data, @@ -436,10 +438,14 @@ static amduat_asl_store_error_t amduat_asl_store_fs_put_impl( free(level2_path); free(object_path); return AMDUAT_ASL_STORE_ERR_INTEGRITY; + } else { + wrote_new = true; } if (!amduat_asl_store_fs_fsync_directory(level2_path)) { - unlink(object_path); + if (wrote_new) { + unlink(object_path); + } amduat_octets_free(&artifact_bytes); amduat_reference_free(&derived_ref); free(objects_path); @@ -451,7 +457,9 @@ static amduat_asl_store_error_t amduat_asl_store_fs_put_impl( return AMDUAT_ASL_STORE_ERR_INTEGRITY; } if (!amduat_asl_store_fs_fsync_directory(fs->root_path)) { - unlink(object_path); + if (wrote_new) { + unlink(object_path); + } amduat_octets_free(&artifact_bytes); amduat_reference_free(&derived_ref); free(objects_path);