Commit 32832943 authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Disable adding files to existing password-protected non-he archives

We don't know the password after opening a non-header-encrypted
password-protected archive. If adding files to such an archive the newly
added files will be unencrypted with no warning to the user and the
resulting archive will be a mixture of encrypted/unencrypted files.

This commit disables adding files to such archives and gives an
explanation in the tooltip for the add files action.

Differential Revision: D2196
parent ad31f89e
......@@ -247,6 +247,11 @@ Archive::EncryptionType Archive::encryptionType()
return m_encryptionType;
QString Archive::password() const
return m_iface->password();
qulonglong Archive::numberOfFiles()
if (!isValid()) {
......@@ -159,6 +159,7 @@ class KERFUFFLE_EXPORT Archive : public QObject
Q_PROPERTY(qulonglong unpackedSize READ unpackedSize)
Q_PROPERTY(qulonglong packedSize READ packedSize)
Q_PROPERTY(QString subfolderName READ subfolderName)
Q_PROPERTY(QString password READ password)
......@@ -179,6 +180,7 @@ public:
bool isMultiVolume() const;
int numberOfVolumes() const;
EncryptionType encryptionType();
QString password() const;
qulonglong numberOfFiles();
qulonglong numberOfFolders();
qulonglong unpackedSize();
......@@ -413,6 +413,22 @@ void Part::updateActions()
bool isDirectory = m_model->entryForIndex(m_view->selectionModel()->currentIndex())[IsDirectory].toBool();
int selectedEntriesCount = m_view->selectionModel()->selectedRows().count();
// We disable adding files if the archive is encrypted but the password is
// unknown (this happens when opening existing non-he password-protected
// archives). If we added files they would not get encrypted resulting in an
// archive with a mixture of encrypted and unencrypted files.
const bool isEncryptedButUnknownPassword = m_model->archive() &&
m_model->archive()->encryptionType() != Archive::Unencrypted &&
if (isEncryptedButUnknownPassword) {
"Adding files to existing password-protected archives with no header-encryption is currently not supported."
"<nl/><nl/>Extract the files and create a new archive if you want to add files."));
} else {
m_addFilesAction->setToolTip(i18nc("@info:tooltip", "Click to add files to the archive"));
// Figure out if entry size is larger than preview size limit.
const int maxPreviewSize = ArkSettings::previewFileSizeLimit() * 1024 * 1024;
const bool limit = ArkSettings::limitPreviewFileSize();
......@@ -430,7 +446,8 @@ void Part::updateActions()
m_saveAsAction->setEnabled(!isBusy() &&
m_model->rowCount() > 0);
m_addFilesAction->setEnabled(!isBusy() &&
isWritable &&
m_deleteFilesAction->setEnabled(!isBusy() &&
isWritable &&
(selectedEntriesCount > 0));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment