Skip to content

Commit

Permalink
UI: Soft-delete scene collections
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
derrod authored and Lain-B committed Jul 8, 2023
1 parent 7166115 commit ad5f04e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions UI/window-basic-main-scene-collections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ad5f04e

Please sign in to comment.