mirror of
https://github.com/QRouland/UTPass.git
synced 2025-02-11 15:07:16 +00:00
Ensure that key and zip are deleted after import
This commit is contained in:
parent
ba52ddac5c
commit
5582b4dd70
@ -29,7 +29,7 @@ void Utils::unzipResult(bool err)
|
|||||||
qDebug() << "Unzip Result";
|
qDebug() << "Unzip Result";
|
||||||
if (err) {
|
if (err) {
|
||||||
qInfo() << "Unzip Failed";
|
qInfo() << "Unzip Failed";
|
||||||
emit unzipFailed("failed to unzip archive");
|
emit unzipFailed();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qInfo() << "Unzip Succeed";
|
qInfo() << "Unzip Succeed";
|
||||||
@ -45,3 +45,14 @@ QString Utils::manifestPath()
|
|||||||
qInfo() << "Manifest path : " << path;
|
qInfo() << "Manifest path : " << path;
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Utils::rmFile(QUrl file_url)
|
||||||
|
{
|
||||||
|
return QFile::remove(file_url.toLocalFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Utils::rmDir(QUrl dir_url)
|
||||||
|
{
|
||||||
|
QDir dir(dir_url.toLocalFile());
|
||||||
|
return dir.removeRecursively();
|
||||||
|
}
|
||||||
|
@ -34,9 +34,8 @@ signals:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Emitted when the unzipping operation fails.
|
* @brief Emitted when the unzipping operation fails.
|
||||||
* @param message The error message describing the failure.
|
|
||||||
*/
|
*/
|
||||||
void unzipFailed(QString message);
|
void unzipFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<QSemaphore> m_sem; /**< Semaphore for managing concurrent operations. */
|
std::unique_ptr<QSemaphore> m_sem; /**< Semaphore for managing concurrent operations. */
|
||||||
@ -48,19 +47,14 @@ public:
|
|||||||
Utils();
|
Utils();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Unzips a ZIP file to the specified output directory.
|
* @brief Start a job to unzips a ZIP file to the specified output directory.
|
||||||
*
|
|
||||||
* This method extracts the contents of a ZIP file from the specified URL and saves them to the provided
|
|
||||||
* output directory path.
|
|
||||||
*
|
*
|
||||||
* @param zip_url The URL of the ZIP file to unzip.
|
* @param zip_url The URL of the ZIP file to unzip.
|
||||||
* @param dir_out The output directory where the contents of the ZIP file should be extracted.
|
* @param dir_out The output directory where the contents of the ZIP file should be extracted.
|
||||||
* @return `true` if the unzipping operation was successful, `false` otherwise.
|
* @return `true` if the unzipping job is started successfullly, `false` otherwise.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE bool unzip(QUrl zip_url, QString dir_out);
|
Q_INVOKABLE bool unzip(QUrl zip_url, QString dir_out);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Retrieves the path to the manifest data.
|
* @brief Retrieves the path to the manifest data.
|
||||||
*
|
*
|
||||||
@ -70,6 +64,22 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE QString manifestPath();
|
Q_INVOKABLE QString manifestPath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes a file located at the specified URL.
|
||||||
|
*
|
||||||
|
* @param file_url The URL of the file to remove.
|
||||||
|
* @return `true` if the file was successfully removed; `false` otherwise.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE bool rmFile(QUrl file_url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes a directory located at the specified URL.
|
||||||
|
*
|
||||||
|
* @param dir_url The URL of the directory to remove.
|
||||||
|
* @return `true` if the directory was successfully removed; `false` otherwise.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE bool rmDir(QUrl dir_url);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,10 +31,12 @@ Page {
|
|||||||
var status = Pass.importGPGKey(importKeyFilePage.activeTransfer.items[0].url);
|
var status = Pass.importGPGKey(importKeyFilePage.activeTransfer.items[0].url);
|
||||||
Pass.importGPGKeySucceed.connect(function() {
|
Pass.importGPGKeySucceed.connect(function() {
|
||||||
importKeyFilePage.activeTransfer = null;
|
importKeyFilePage.activeTransfer = null;
|
||||||
|
Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url);
|
||||||
PopupUtils.open(dialogImportKeyPageSucess);
|
PopupUtils.open(dialogImportKeyPageSucess);
|
||||||
});
|
});
|
||||||
Pass.importGPGKeyFailed.connect(function(message) {
|
Pass.importGPGKeyFailed.connect(function(message) {
|
||||||
importKeyFilePage.activeTransfer = null;
|
importKeyFilePage.activeTransfer = null;
|
||||||
|
Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url);
|
||||||
PopupUtils.open(dialogImportKeyPageError);
|
PopupUtils.open(dialogImportKeyPageError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,12 @@ Page {
|
|||||||
var status = Utils.unzip(importZipPage.activeTransfer.items[0].url, Pass.getPasswordStore());
|
var status = Utils.unzip(importZipPage.activeTransfer.items[0].url, Pass.getPasswordStore());
|
||||||
Utils.unzipSucceed.connect(function() {
|
Utils.unzipSucceed.connect(function() {
|
||||||
importZipPage.activeTransfer = null;
|
importZipPage.activeTransfer = null;
|
||||||
|
Utils.rmFile(importZipPage.activeTransfer.items[0].url);
|
||||||
PopupUtils.open(dialogImportZipPageSuccess);
|
PopupUtils.open(dialogImportZipPageSuccess);
|
||||||
});
|
});
|
||||||
Utils.unzipFailed.connect(function(message) {
|
Utils.unzipFailed.connect(function() {
|
||||||
importZipPage.activeTransfer = null;
|
importZipPage.activeTransfer = null;
|
||||||
|
Utils.rmFile(importZipPage.activeTransfer.items[0].url);
|
||||||
PopupUtils.open(dialogImportZipPageError);
|
PopupUtils.open(dialogImportZipPageError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -89,11 +89,10 @@ Page {
|
|||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
text: {
|
text: {
|
||||||
if (!model.modelData) {
|
if (!model.modelData)
|
||||||
"";
|
"";
|
||||||
} else {
|
else
|
||||||
model.modelData.keyid;
|
model.modelData.keyid;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
color: theme.palette.normal.backgroundText
|
color: theme.palette.normal.backgroundText
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user