bugfix deleting target file after write failure
authorLukas Hrazky <lukkash@email.cz>
Sun, 25 Jul 2010 12:58:29 +0000 (14:58 +0200)
committerLukas Hrazky <lukkash@email.cz>
Sun, 25 Jul 2010 12:58:29 +0000 (14:58 +0200)
Signed-off-by: Lukas Hrazky <lukkash@email.cz>

src/fileoperator.cpp

index fc826b9..90cb7da 100644 (file)
@@ -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)