1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-01-24 23:56:39 +00:00
UTPass/plugins/Git/git.cpp

34 lines
1.2 KiB
C++
Raw Normal View History

2025-01-10 13:48:38 +01:00
#include <QUrl>
#include <QtCore/QDir>
#include <QDebug>
#include <QStandardPaths>
2025-01-10 13:48:38 +01:00
#include "git.h"
#include "libgit.h"
bool Git::clone(QString url, QString destination_dir_path)
2025-01-10 13:48:38 +01:00
{
qInfo() << "Cloning " << url << " to destination " << destination_dir_path;
QDir tmp_dir(QStandardPaths::writableLocation(
QStandardPaths::CacheLocation).append("/clone"));
tmp_dir.removeRecursively();
qDebug() << "Temp dir path is " << tmp_dir.absolutePath();
qDebug() << "Cloning " << url << " to tmp dir " << tmp_dir.absolutePath();
auto ret = LibGit::instance()->clone(url, tmp_dir.absolutePath()); // TODO Better error handling
2025-01-10 15:28:42 +01:00
if (ret) {
qDebug() << "Removing password_store " << destination_dir_path;
QDir destination_dir(destination_dir_path);
destination_dir.removeRecursively();
qDebug() << "Moving cloned content to destination dir";
QDir dir;
qDebug() << tmp_dir.absolutePath() << " to " << destination_dir.absolutePath();
ret = dir.rename(tmp_dir.absolutePath(), destination_dir.absolutePath()); // TODO Better error handling
}
//tmp_dir.removeRecursively();
return ret ;
2025-01-10 13:48:38 +01:00
}