Commit 0aea5265 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix adding description to archive

parent 33987346
......@@ -71,7 +71,7 @@ void ExportAddressbookJobInterfaceTest::exportAddressBookConfigTest1()
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
Utils::storeDataExportInfo(storeArchivePath, archiveStorage->archive());
Utils::storeDataExportInfo( archiveStorage->archive());
ExportAddressbookJobInterfaceTestImpl *exportNote = new ExportAddressbookJobInterfaceTestImpl(this, {Utils::StoredType::Config}, archiveStorage, 1);
QSignalSpy finish(exportNote, &ExportAddressbookJobInterfaceTestImpl::jobFinished);
......
......@@ -54,7 +54,7 @@ void ExportAkregatorJobInterfaceTest::exportAkregatorConfigTest1()
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
Utils::storeDataExportInfo(storeArchivePath, archiveStorage->archive());
Utils::storeDataExportInfo( archiveStorage->archive());
ExportAkregatorJobInterfaceTestImpl *exportNote = new ExportAkregatorJobInterfaceTestImpl(this, {Utils::StoredType::Config}, archiveStorage, 1);
QSignalSpy finish(exportNote, &ExportAkregatorJobInterfaceTestImpl::jobFinished);
......
......@@ -59,7 +59,7 @@ void ExportAlarmJobInterfaceTest::exportAlarmConfigTest1()
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
Utils::storeDataExportInfo(storeArchivePath, archiveStorage->archive());
Utils::storeDataExportInfo( archiveStorage->archive());
ExportAlarmJobInterfaceTestImpl *exportNote = new ExportAlarmJobInterfaceTestImpl(this, {Utils::StoredType::Config}, archiveStorage, 1);
QSignalSpy finish(exportNote, &ExportAlarmJobInterfaceTestImpl::jobFinished);
......
......@@ -59,7 +59,7 @@ void ExportCalendarsJobInterfaceTest::exportCalendarConfigTest1()
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
Utils::storeDataExportInfo(storeArchivePath, archiveStorage->archive());
Utils::storeDataExportInfo( archiveStorage->archive());
ExportCalendarsJobInterfaceTestImpl *exportNote = new ExportCalendarsJobInterfaceTestImpl(this, {Utils::StoredType::Config}, archiveStorage, 1);
QSignalSpy finish(exportNote, &ExportCalendarsJobInterfaceTestImpl::jobFinished);
......
......@@ -82,7 +82,7 @@ void ExportMailJobInterfaceTest::exportMailConfigTest1()
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
Utils::storeDataExportInfo(storeArchivePath, archiveStorage->archive());
Utils::storeDataExportInfo( archiveStorage->archive());
ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, {Utils::StoredType::Config}, archiveStorage, 1);
QSignalSpy finish(exportNote, &ExportMailJobInterfaceTestImpl::jobFinished);
......
......@@ -67,12 +67,12 @@ void ExportNotesJobInterfaceTest::exportNoteConfigTest1()
qputenv("XDG_CONFIG_HOME", PIMDATAEXPORTER_DIR "/export/test1/config");
//TODO fix file name.
const QString temporaryFile = QStringLiteral("/tmp/foo.zip");
const QString storeArchivePath(temporaryFile);
ArchiveStorage *archiveStorage = new ArchiveStorage(storeArchivePath, this);
const QString temporaryFile = QDir::tempPath() + QStringLiteral("/archive.zip");
ArchiveStorage *archiveStorage = new ArchiveStorage(temporaryFile, this);
Q_ASSERT(archiveStorage->openArchive(true));
Utils::addVersion(archiveStorage->archive());
Utils::storeDataExportInfo(storeArchivePath, archiveStorage->archive());
//qDebug() << " temporaryFile " << temporaryFile;
Utils::storeDataExportInfo(archiveStorage->archive());
ExportNotesJobInterfaceTestImpl *exportNote = new ExportNotesJobInterfaceTestImpl(this, {Utils::StoredType::Config}, archiveStorage, 1);
QSignalSpy finish(exportNote, &ExportNotesJobInterfaceTestImpl::jobFinished);
......@@ -87,4 +87,5 @@ void ExportNotesJobInterfaceTest::exportNoteConfigTest1()
compareExportFile.setTempFilePath(temporaryFile);
compareExportFile.setListFilePath(QStringLiteral(PIMDATAEXPORTER_DIR "/export/test1"));
compareExportFile.compareFiles();
QVERIFY(QFile(temporaryFile).remove());
}
......@@ -110,7 +110,7 @@ bool PimDataBackupRestore::backupStart(const QString &filename)
Utils::addVersion(mArchiveStorage->archive());
//Add exported file info.
//qDebug() << "mExportedInfoFileName" << mExportedInfoFileName;
Utils::storeDataExportInfo(mExportedInfoFileName, mArchiveStorage->archive());
Utils::storeDataExportInfo(mArchiveStorage->archive());
backupNextStep();
return true;
}
......
......@@ -172,15 +172,14 @@ KZip *Utils::openZip(const QString &filename, QString &errorMsg)
return zip;
}
void Utils::storeDataExportInfo(const QString &filename, KZip *archive)
void Utils::storeDataExportInfo(KZip *archive)
{
if (QFileInfo::exists(filename)) {
const bool fileAdded = archive->addLocalFile(filename, Utils::infoPath() + Utils::exportDataTypeFileName());
if (fileAdded) {
qCDebug(PIMDATAEXPORTERCORE_LOG) << "exporteddata file can not add to archive" << filename << " to " << Utils::infoPath() + Utils::exportDataTypeFileName();
}
} else {
qCDebug(PIMDATAEXPORTERCORE_LOG) << "exported file was not created" << filename;
QTemporaryFile tmp;
tmp.open();
const bool fileAdded = archive->addLocalFile(tmp.fileName(), Utils::infoPath() + Utils::exportDataTypeFileName());
qDebug() << " fileAdded "<< fileAdded;
if (fileAdded) {
qCDebug(PIMDATAEXPORTERCORE_LOG) << "storeDataExportInfo can't add to archive";
}
}
......
......@@ -95,7 +95,7 @@ Q_REQUIRED_RESULT QString akonadiAgentName(const QString &configPath);
Q_REQUIRED_RESULT QString storeResources(KZip *archive, const QString &identifier, const QString &path);
KZip *openZip(const QString &filename, QString &errorMsg);
PIMDATAEXPORTER_EXPORT void storeDataExportInfo(const QString &filename, KZip *archive);
PIMDATAEXPORTER_EXPORT void storeDataExportInfo(KZip *archive);
PIMDATAEXPORTER_EXPORT void addVersion(KZip *archive);
Q_REQUIRED_RESULT int archiveVersion(KZip *archive);
......
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