Commit e3437a20 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Try to compare file.

parent d346a29c
......@@ -23,6 +23,7 @@
#include <QTest>
#include <QDebug>
#include <QProcess>
#include <KZip>
CompareExportFile::CompareExportFile()
{
......@@ -30,6 +31,10 @@ CompareExportFile::CompareExportFile()
CompareExportFile::~CompareExportFile()
{
delete mZip;
mZip = nullptr;
delete mTempDir;
mTempDir = nullptr;
}
void CompareExportFile::compareFiles()
......@@ -45,10 +50,36 @@ void CompareExportFile::compareFiles()
qDebug() << "List File : " << archiveList;
}
QVERIFY(equal);
mZip = new KZip(mTempFilePath);
//qDebug() << " mFileName" << mFileName;
const bool result = mZip->open(QIODevice::ReadOnly);
QVERIFY(result);
const KArchiveDirectory *topDirectory = mZip->directory();
for (const QString &file : archiveList) {
qDebug() << " file " << file;
const KArchiveEntry *currentEntry = topDirectory->entry(file);
if (currentEntry && currentEntry->isFile()) {
if (!mTempDir) {
mTempDir = new QTemporaryDir;
mTempDir->setAutoRemove(false);
}
const KArchiveFile *currentFile = static_cast<const KArchiveFile *>(currentEntry);
QString adaptFile = file;
adaptFile.replace(QStringLiteral("configs/"), QStringLiteral("config/"));
const QString fileName = mTempDir->path() + QLatin1Char('/') + adaptFile;
QFile f(fileName);
qDebug() << " fileName" << fileName;
QVERIFY(f.open(QIODevice::WriteOnly));
const QByteArray data = currentFile->data();
QCOMPARE(f.write(data), data.length());
qDebug() << "********** " << mTempDir->path() + QLatin1Char('/') + file;
compareFile(mListFilePath + QStringLiteral("/references/") + adaptFile, fileName);
}
}
//TODO compare files
}
void CompareExportFile::compareFile(const QString &referenceFile, const QString &archiveFile)
......
......@@ -21,7 +21,8 @@
#define COMPAREEXPORTFILE_H
#include <QString>
class KZip;
class QTemporaryDir;
class CompareExportFile
{
public:
......@@ -39,6 +40,8 @@ private:
void compareFile(const QString &referenceFile, const QString &archiveFile);
QString mTempFilePath;
QString mListFilePath;
KZip *mZip = nullptr;
QTemporaryDir *mTempDir = nullptr;
};
#endif // COMPAREEXPORTFILE_H
......@@ -37,7 +37,7 @@ GenerateListFileFromArchive::~GenerateListFileFromArchive()
void GenerateListFileFromArchive::generateList()
{
mZip = new KZip(mFileName);
qDebug() << " mFileName" << mFileName;
//qDebug() << " mFileName" << mFileName;
bool result = mZip->open(QIODevice::ReadOnly);
QVERIFY(result);
const KArchiveDirectory *topDirectory = mZip->directory();
......
......@@ -47,6 +47,13 @@ void ExportNotesJobInterfaceTestImpl::exportArchiveResource()
qDebug() << " not implement yet";
}
Akonadi::Collection::Id ExportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
ExportNotesJobInterfaceTest::ExportNotesJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -81,10 +88,3 @@ void ExportNotesJobInterfaceTest::exportNoteConfigTest1()
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
}
Akonadi::Collection::Id ExportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
Markdown is supported
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