From c343dbaa63230746165e1666bd6314fda73ce678 Mon Sep 17 00:00:00 2001 From: Lukas Hrazky Date: Sun, 25 Jul 2010 14:58:29 +0200 Subject: [PATCH] bugfix deleting target file after write failure Signed-off-by: Lukas Hrazky --- src/fileoperator.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fileoperator.cpp b/src/fileoperator.cpp index fc826b9..90cb7da 100644 --- a/src/fileoperator.cpp +++ b/src/fileoperator.cpp @@ -516,7 +516,7 @@ void FileManipulatorThread::copy(const QFileInfo &file) { SPECIAL_COPY_ERROR_PROMPT(!engine.open(QIODevice::ReadOnly), tr("Error reading file %1."), path) - bool ignore = false; + bool ignore = false, newFileWritten = false; while (!abort && !ignore) { engine.seek(0); fileValue = 0; @@ -533,6 +533,8 @@ void FileManipulatorThread::copy(const QFileInfo &file) { break; } + newFileWritten = true; + bool error = false; char block[BLOCK_SIZE]; qint64 bytes; @@ -567,7 +569,9 @@ void FileManipulatorThread::copy(const QFileInfo &file) { newEngine.close(); if (abort || ignore) { - newEngine.remove(); + if (newFileWritten) { + newEngine.remove(); + } } else { ERROR_PROMPT(!newEngine.setPermissions(file.permissions()), tr("Error setting permissions for file %1."), newPath) -- 1.7.9.5