From 1612e4372b8b76e2e0b1c43e6f5e5facdb89ad6f Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 27 Sep 2021 20:50:37 +0200 Subject: [PATCH] SaveTool: make the file watcher less aggressive. --- src/SaveTool/SaveTool.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 97887ec..900823b 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -206,6 +206,8 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, return; } + static bool is_moved_after_save = false; + switch(action) { case efsw::Actions::Add: if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) { @@ -229,9 +231,6 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, if(!_currentMass || _currentMass != &(_massManager->hangar(index))) { _massManager->refreshHangar(index); } - else { - _currentMass->setDirty(); - } } } break; @@ -248,7 +247,10 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, _massManager->refreshHangar(index); } else { - _currentMass->setDirty(); + if(!is_moved_after_save) { + is_moved_after_save = false; + _currentMass->setDirty(); + } } } } @@ -256,6 +258,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, case efsw::Actions::Moved: if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) { if(Utility::String::endsWith(old_filename, ".tmp")) { + is_moved_after_save = true; return; }