diff --git a/apps/ll-driver-detect/src/driver_detection_config.cpp b/apps/ll-driver-detect/src/driver_detection_config.cpp index daf06f297..74d8f786a 100644 --- a/apps/ll-driver-detect/src/driver_detection_config.cpp +++ b/apps/ll-driver-detect/src/driver_detection_config.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -64,6 +64,11 @@ bool DriverDetectionConfigManager::saveConfig() file << jsonConfig.dump(4); // Pretty print with 4 spaces file.close(); + if (!file.good()) { + LogW("failed to write driver detection config to {}", configFilePath); + return false; + } + return true; } diff --git a/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp b/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp index 042b228a0..8e891cd2d 100644 --- a/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp +++ b/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. + * SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. * * SPDX-License-Identifier: LGPL-3.0-or-later */ @@ -69,3 +69,14 @@ TEST_F(DriverDetectionConfigTest, SaveAndLoadConfig) auto loadedConfig = manager2.getConfig(); EXPECT_TRUE(loadedConfig.neverRemind); } + +TEST_F(DriverDetectionConfigTest, SaveConfigFailsOnWriteError) +{ + using namespace linglong::driver::detect; + + // Opening /dev/full succeeds but every write fails with ENOSPC; if the + // device is unavailable the open itself fails, so the save must report + // failure either way instead of silently losing the user's choice + DriverDetectionConfigManager manager("/dev/full"); + EXPECT_FALSE(manager.saveConfig()); +}