diff --git a/plugins/libarchive/readwritelibarchiveplugin.cpp b/plugins/libarchive/readwritelibarchiveplugin.cpp --- a/plugins/libarchive/readwritelibarchiveplugin.cpp +++ b/plugins/libarchive/readwritelibarchiveplugin.cpp @@ -305,15 +305,19 @@ qCDebug(ARK) << "Added" << no_entries << "old entries to archive"; } - m_abortOperation = false; // In the success case, we need to manually close the archive_writer before // calling QSaveFile::commit(), otherwise the latter will close() the // file descriptor archive_writer is still working on. // TODO: We need to abstract this code better so that we only deal with one // object that manages both QSaveFile and ArchiveWriter. archive_write_close(arch_writer.data()); - tempFile.commit(); + // #365869: avoid data loss if we are aborting the job. + if (!m_abortOperation) { + tempFile.commit(); + } + + m_abortOperation = false; return true; } @@ -456,15 +460,18 @@ } qCDebug(ARK) << "Removed" << no_entries << "entries from archive"; - m_abortOperation = false; - // In the success case, we need to manually close the archive_writer before // calling QSaveFile::commit(), otherwise the latter will close() the // file descriptor archive_writer is still working on. // TODO: We need to abstract this code better so that we only deal with one // object that manages both QSaveFile and ArchiveWriter. archive_write_close(arch_writer.data()); - tempFile.commit(); + // #365869: avoid data loss if we are aborting the job. + if (!m_abortOperation) { + tempFile.commit(); + } + + m_abortOperation = false; return true; }