From 0b726b03d0d5c018004af438c8080f8d5ea7d432 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Fri, 10 Apr 2026 04:18:14 -0500 Subject: Fix backup restore failing when destination file already exists QFile::copy() does not overwrite existing files, unlike Windows SHFileOperation. Remove destination before copying to match the expected overwrite behavior. Co-Authored-By: Claude Opus 4.6 (1M context) --- libs/uibase/src/utility.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libs') diff --git a/libs/uibase/src/utility.cpp b/libs/uibase/src/utility.cpp index 94cbc77..c0070c6 100644 --- a/libs/uibase/src/utility.cpp +++ b/libs/uibase/src/utility.cpp @@ -152,6 +152,7 @@ static bool shellOpCopy(const QStringList& sourceNames, for (const auto& src : sourceNames) { QFileInfo srcInfo(src); QString dest = destinationNames[0] + "/" + srcInfo.fileName(); + QFile::remove(dest); if (!QFile::copy(src, dest)) { return false; } @@ -169,6 +170,7 @@ static bool shellOpCopy(const QStringList& sourceNames, if (!destInfo.dir().exists()) { destInfo.dir().mkpath("."); } + QFile::remove(destinationNames[i]); if (!QFile::copy(sourceNames[i], destinationNames[i])) { return false; } -- cgit v1.3.1