Skip to content

Make the "Extract and delete archive" file item action plugin work

Jonathan Marten requested to merge marten/ark:batchextract-fix-delete into master

The problem was that the archive would be correctly extracted but the source file did not actually get deleted. This happened because the lambda connection in ExtractFileItemAction::createAction() to the BatchExtractJob::finished() signal included a context of 'this'. This means that all signal connections from the ExtractFileItemAction would be removed when it was deleted - in other words, as soon as the action had been triggered but before the extraction had finished. Therefore the lambda body which deletes the source archive would never be executed.

It would suffice to remove the 'this' context in the signal connection above, but it is possible that a future Qt update or a future change to the KDE compiler settings may not allow a contextless connection.

This change therefore moves the code to delete the source archive - and also, for consistency, to open the destination in a file manager - to be a subjob of the BatchExtractJob. This ensures that they run before the entire job completes. The BatchExtractJob has a flag with setter/ getter functions to control whether the source archive is deleted. In order to distinguish the three possible subjob types that a BatchExtractJob may contain, QObject properties attached to the jobs are used to store their file information instead of needing to use the m_fileNames map.

Merge request reports

Loading