From 2f15449a0af624cfc242e9eb927eb75c061656b1 Mon Sep 17 00:00:00 2001 From: Adisu Date: Thu, 2 Jul 2026 07:16:43 +0300 Subject: [PATCH 1/3] fix: use task.id instead of task.name for config lookups --- .gitignore | 3 +++ src/config_manager.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index aa3ea71..e247b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ vcpkg_installed/ # test output & cache Testing/ .cache/ + +#system metadata +*.DS_Store diff --git a/src/config_manager.cpp b/src/config_manager.cpp index edf99aa..4bd3896 100644 --- a/src/config_manager.cpp +++ b/src/config_manager.cpp @@ -221,7 +221,7 @@ namespace flowhook for (auto &t : config_obj["tasks"]) { Task _ts = TRY(convert_json_to_task(t), void); - if (_ts.name == task.name) + if (_ts.id == task.id) { return Result::Err(FWError::make( ErrorCode::TASK_ALREADY_EXISTS, "Error: task already exists, use update_task to update it")); @@ -238,8 +238,8 @@ namespace flowhook { for (auto it = config_obj["tasks"].begin(); it != config_obj["tasks"].end(); it++) { - string name = it->at("task_name"); - if (name == task.name) + string id = it->at("working_directory"); + if (id == task.id) { json _json_task = TRY(convert_task_to_json(task), void); *it = _json_task; @@ -277,8 +277,8 @@ namespace flowhook { for (auto it = config_obj["tasks"].begin(); it != config_obj["tasks"].end(); it++) { - string name = it->at("task_name"); - if (name == task.name) + string id = it->at("working_directory"); + if (id == task.id) { config_obj["tasks"].erase(it); return Result::Ok(); From 59ee637f9167eba55ef1245fd6a1598af3d48f5f Mon Sep 17 00:00:00 2001 From: Adisu Date: Thu, 2 Jul 2026 18:06:18 +0300 Subject: [PATCH 2/3] fix t3.id to match t.id in update_task test --- tests/unit/test_config_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_config_manager.cpp b/tests/unit/test_config_manager.cpp index 478c9eb..b4cbb3e 100644 --- a/tests/unit/test_config_manager.cpp +++ b/tests/unit/test_config_manager.cpp @@ -42,7 +42,7 @@ UTEST_F_SETUP(ConfigManagerFixture) utest_fixture->t2 = new Task("test_task2", "/tmp/cm_test2", 3, {"ls"}, {"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector{"ls"}, vector{"cd, ls"}, {"*.o"}, {".git"}, true, true); - utest_fixture->t3 = new Task("test_task1", "/tmp/cm_test", 3, {"cd", "make"}, + utest_fixture->t3 = new Task("test_task", "/tmp/cm_test", 3, {"cd", "make"}, {"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector{"ls"}, vector{"cd, ls"}, {"*.o"}, {".git"}, true, true); } From c3172369ac1a7df8aaba4b05d7da6d42edebf8ae Mon Sep 17 00:00:00 2001 From: Adisu Date: Thu, 2 Jul 2026 21:12:22 +0300 Subject: [PATCH 3/3] swap task.id and task.name args --- tests/unit/test_config_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_config_manager.cpp b/tests/unit/test_config_manager.cpp index b4cbb3e..1f0a115 100644 --- a/tests/unit/test_config_manager.cpp +++ b/tests/unit/test_config_manager.cpp @@ -36,13 +36,13 @@ UTEST_F_SETUP(ConfigManagerFixture) fs::create_directories("/tmp/cm_test"); fs::create_directories("/tmp/cm_test2"); - utest_fixture->t = new Task("test_task", "/tmp/cm_test", 3, {"ls"}, + utest_fixture->t = new Task("/tmp/cm_test", "test_task", 3, {"ls"}, {"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector{"ls"}, vector{"ls"}, {"*.o"}, {".git"}, true, true); utest_fixture->t2 = new Task("test_task2", "/tmp/cm_test2", 3, {"ls"}, {"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector{"ls"}, vector{"cd, ls"}, {"*.o"}, {".git"}, true, true); - utest_fixture->t3 = new Task("test_task", "/tmp/cm_test", 3, {"cd", "make"}, + utest_fixture->t3 = new Task("/tmp/cm_test", "test_task", 3, {"cd", "make"}, {"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector{"ls"}, vector{"cd, ls"}, {"*.o"}, {".git"}, true, true); }