From ad5f04e53dc6ed740138c0950b1042b3e24d1ba3 Mon Sep 17 00:00:00 2001 From: derrod Date: Tue, 4 Jul 2023 10:44:16 +0200 Subject: [PATCH] UI: Soft-delete scene collections Instead of actually removing the file, simply rename it to the .bak version which OBS ignores in most cases. That allows users to recover accidentally deleted collections more easily, while only taking up a few kilobytes of disk space at most. --- UI/window-basic-main-scene-collections.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/UI/window-basic-main-scene-collections.cpp b/UI/window-basic-main-scene-collections.cpp index ab0ab70e8..0fe0867ed 100644 --- a/UI/window-basic-main-scene-collections.cpp +++ b/UI/window-basic-main-scene-collections.cpp @@ -343,11 +343,8 @@ void OBSBasic::on_actionRemoveSceneCollection_triggered() api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING); oldFile.insert(0, path); - oldFile += ".json"; - - os_unlink(oldFile.c_str()); - oldFile += ".bak"; - os_unlink(oldFile.c_str()); + /* os_rename() overwrites if necessary, only the .bak file will remain. */ + os_rename((oldFile + ".json").c_str(), (oldFile + ".json.bak").c_str()); Load(newPath.c_str()); RefreshSceneCollections();