From: Lukas Hrazky Date: Sun, 25 Jul 2010 12:58:29 +0000 (+0200) Subject: bugfix deleting target file after write failure X-Git-Tag: v0.1.2~1 X-Git-Url: https://vcs.maemo.org/git/?p=case;a=commitdiff_plain;h=c343dbaa63230746165e1666bd6314fda73ce678 bugfix deleting target file after write failure Signed-off-by: Lukas Hrazky --- 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)