mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added log messages for creating/updating libraries
This commit is contained in:
parent
e51480469f
commit
f75d0abef0
@ -12,6 +12,8 @@
|
|||||||
#include "compressed_archive.h"
|
#include "compressed_archive.h"
|
||||||
#include "comic.h"
|
#include "comic.h"
|
||||||
|
|
||||||
|
#include "QsLog.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -57,6 +59,7 @@ void LibraryCreator::run()
|
|||||||
|
|
||||||
if(_mode == CREATOR)
|
if(_mode == CREATOR)
|
||||||
{
|
{
|
||||||
|
QLOG_INFO() << "Starting to create new library ( " << _source << "," << _target << ")";
|
||||||
_currentPathFolders.clear();
|
_currentPathFolders.clear();
|
||||||
_currentPathFolders.append(Folder(1,1,"root","/"));
|
_currentPathFolders.append(Folder(1,1,"root","/"));
|
||||||
//se crean los directorios .yacreaderlibrary y .yacreaderlibrary/covers
|
//se crean los directorios .yacreaderlibrary y .yacreaderlibrary/covers
|
||||||
@ -67,6 +70,7 @@ void LibraryCreator::run()
|
|||||||
_database = DataBaseManagement::createDatabase("library",_target);//
|
_database = DataBaseManagement::createDatabase("library",_target);//
|
||||||
if(!_database.isOpen())
|
if(!_database.isOpen())
|
||||||
{
|
{
|
||||||
|
QLOG_ERROR() << "Unable to create data base" << _database.lastError().databaseText() + "-" + _database.lastError().driverText();
|
||||||
emit failedCreatingDB(_database.lastError().databaseText() + "-" + _database.lastError().driverText());
|
emit failedCreatingDB(_database.lastError().databaseText() + "-" + _database.lastError().driverText());
|
||||||
emit finished();
|
emit finished();
|
||||||
creation = false;
|
creation = false;
|
||||||
@ -81,15 +85,18 @@ void LibraryCreator::run()
|
|||||||
_database.close();
|
_database.close();
|
||||||
QSqlDatabase::removeDatabase(_database.connectionName());
|
QSqlDatabase::removeDatabase(_database.connectionName());
|
||||||
emit(created());
|
emit(created());
|
||||||
|
QLOG_INFO() << "Create library END";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
QLOG_INFO() << "Starting to update library ( " << _source << "," << _target << ")";
|
||||||
_currentPathFolders.clear();
|
_currentPathFolders.clear();
|
||||||
_currentPathFolders.append(Folder(1,1,"root","/"));
|
_currentPathFolders.append(Folder(1,1,"root","/"));
|
||||||
_database = DataBaseManagement::loadDatabase(_target);
|
_database = DataBaseManagement::loadDatabase(_target);
|
||||||
//_database.setDatabaseName(_target+"/library.ydb");
|
//_database.setDatabaseName(_target+"/library.ydb");
|
||||||
if(!_database.open())
|
if(!_database.open())
|
||||||
{
|
{
|
||||||
|
QLOG_ERROR() << "Unable to open data base" << _database.lastError().databaseText() + "-" + _database.lastError().driverText();
|
||||||
emit failedOpeningDB(_database.lastError().databaseText() + "-" + _database.lastError().driverText());
|
emit failedOpeningDB(_database.lastError().databaseText() + "-" + _database.lastError().driverText());
|
||||||
emit finished();
|
emit finished();
|
||||||
creation = false;
|
creation = false;
|
||||||
@ -106,6 +113,7 @@ void LibraryCreator::run()
|
|||||||
emit(updated());
|
emit(updated());
|
||||||
else
|
else
|
||||||
emit(created());
|
emit(created());
|
||||||
|
QLOG_INFO() << "Update library END";
|
||||||
}
|
}
|
||||||
msleep(100);//TODO try to solve the problem with the udpate dialog (ya no se usa más...)
|
msleep(100);//TODO try to solve the problem with the udpate dialog (ya no se usa más...)
|
||||||
emit(finished());
|
emit(finished());
|
||||||
@ -421,7 +429,7 @@ void LibraryCreator::update(QDir dirS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target="", int coverPage)
|
ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target, int coverPage)
|
||||||
:_fileSource(fileSource),_target(target),_numPages(0),_coverPage(coverPage)
|
:_fileSource(fileSource),_target(target),_numPages(0),_coverPage(coverPage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -432,6 +440,7 @@ void ThumbnailCreator::create()
|
|||||||
if(!fi.exists()) //TODO: error file not found.
|
if(!fi.exists()) //TODO: error file not found.
|
||||||
{
|
{
|
||||||
_cover.load(":/images/notCover.png");
|
_cover.load(":/images/notCover.png");
|
||||||
|
QLOG_WARN() << "Extracting cover: file not found " << _fileSource;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,6 +449,7 @@ void ThumbnailCreator::create()
|
|||||||
Poppler::Document * pdfComic = Poppler::Document::load(_fileSource);
|
Poppler::Document * pdfComic = Poppler::Document::load(_fileSource);
|
||||||
if (!pdfComic)
|
if (!pdfComic)
|
||||||
{
|
{
|
||||||
|
QLOG_WARN() << "Extracting cover: unable to open PDF file " << _fileSource;
|
||||||
delete pdfComic;
|
delete pdfComic;
|
||||||
pdfComic = 0;
|
pdfComic = 0;
|
||||||
QImage p;
|
QImage p;
|
||||||
@ -451,7 +461,7 @@ void ThumbnailCreator::create()
|
|||||||
if(_numPages >= _coverPage)
|
if(_numPages >= _coverPage)
|
||||||
{
|
{
|
||||||
|
|
||||||
QImage p = pdfComic->page(_coverPage-1)->renderToImage(72,72); //TODO check if the the page is valid
|
QImage p = pdfComic->page(_coverPage-1)->renderToImage(72,72); //TODO check if the page is valid
|
||||||
_cover = QPixmap::fromImage(p);
|
_cover = QPixmap::fromImage(p);
|
||||||
if(_target!="")
|
if(_target!="")
|
||||||
{
|
{
|
||||||
@ -465,6 +475,7 @@ void ThumbnailCreator::create()
|
|||||||
}
|
}
|
||||||
else if(_target!="")
|
else if(_target!="")
|
||||||
{
|
{
|
||||||
|
QLOG_WARN() << "Extracting cover: requested cover index greater than numPages " << _fileSource;
|
||||||
QImage p;
|
QImage p;
|
||||||
p.load(":/images/notCover.png");
|
p.load(":/images/notCover.png");
|
||||||
p.save(_target);
|
p.save(_target);
|
||||||
@ -474,12 +485,15 @@ void ThumbnailCreator::create()
|
|||||||
{
|
{
|
||||||
|
|
||||||
CompressedArchive archive(_fileSource);
|
CompressedArchive archive(_fileSource);
|
||||||
|
if(!archive.isValid())
|
||||||
|
QLOG_WARN() << "Extracting cover: file format not supported " << _fileSource;
|
||||||
//se filtran para obtener sólo los formatos soportados
|
//se filtran para obtener sólo los formatos soportados
|
||||||
QList<QString> order = archive.getFileNames();
|
QList<QString> order = archive.getFileNames();
|
||||||
QList<QString> fileNames = FileComic::filter(order);
|
QList<QString> fileNames = FileComic::filter(order);
|
||||||
_numPages = fileNames.size();
|
_numPages = fileNames.size();
|
||||||
if(_numPages == 0)
|
if(_numPages == 0)
|
||||||
{
|
{
|
||||||
|
QLOG_WARN() << "Extracting cover: empty comic " << _fileSource;
|
||||||
_cover.load(":/images/notCover.png");
|
_cover.load(":/images/notCover.png");
|
||||||
if(_target!="")
|
if(_target!="")
|
||||||
_cover.save(_target);
|
_cover.save(_target);
|
||||||
@ -494,7 +508,10 @@ void ThumbnailCreator::create()
|
|||||||
if(_target=="")
|
if(_target=="")
|
||||||
{
|
{
|
||||||
if(!_cover.loadFromData(archive.getRawDataAtIndex(index)))
|
if(!_cover.loadFromData(archive.getRawDataAtIndex(index)))
|
||||||
|
{
|
||||||
|
QLOG_WARN() << "Extracting cover: unable to load image from extracted cover " << _fileSource;
|
||||||
_cover.load(":/images/notCover.png");
|
_cover.load(":/images/notCover.png");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -510,6 +527,7 @@ void ThumbnailCreator::create()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
QLOG_WARN() << "Extracting cover: unable to load image from extracted cover " << _fileSource;
|
||||||
p.load(":/images/notCover.png");
|
p.load(":/images/notCover.png");
|
||||||
p.save(_target);
|
p.save(_target);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThumbnailCreator(QString fileSource, QString target, int coverPage = 1);
|
ThumbnailCreator(QString fileSource, QString target="", int coverPage = 1);
|
||||||
private:
|
private:
|
||||||
QString _fileSource;
|
QString _fileSource;
|
||||||
QString _target;
|
QString _target;
|
||||||
|
@ -107,7 +107,7 @@ void logSystemAndConfig()
|
|||||||
|
|
||||||
QSettings settings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
settings.beginGroup("libraryConfig");
|
settings.beginGroup("libraryConfig");
|
||||||
if(settings.value(SERVER_ON).toBool())
|
if(settings.value(SERVER_ON,true).toBool())
|
||||||
QLOG_INFO() << "server : enabled";
|
QLOG_INFO() << "server : enabled";
|
||||||
else
|
else
|
||||||
QLOG_INFO() << "server : disabled";
|
QLOG_INFO() << "server : disabled";
|
||||||
|
@ -56,7 +56,7 @@ struct SevenZipInterface {
|
|||||||
//SevenZipInterface * szInterface;
|
//SevenZipInterface * szInterface;
|
||||||
|
|
||||||
CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) :
|
CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) :
|
||||||
QObject(parent),sevenzLib(0)
|
QObject(parent),sevenzLib(0),valid(false)
|
||||||
{
|
{
|
||||||
szInterface = new SevenZipInterface;
|
szInterface = new SevenZipInterface;
|
||||||
//load functions
|
//load functions
|
||||||
@ -90,7 +90,7 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
|
|||||||
|
|
||||||
if (szInterface->archive->Open(file, 0, openCallback) == S_OK)
|
if (szInterface->archive->Open(file, 0, openCallback) == S_OK)
|
||||||
{
|
{
|
||||||
formatFound = true;
|
valid = formatFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,6 +165,11 @@ QList<QString> CompressedArchive::getFileNames()
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CompressedArchive::isValid()
|
||||||
|
{
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
int CompressedArchive::getNumFiles()
|
int CompressedArchive::getNumFiles()
|
||||||
{
|
{
|
||||||
quint32 numItems = 0;
|
quint32 numItems = 0;
|
||||||
@ -211,4 +216,4 @@ QByteArray CompressedArchive::getRawDataAtIndex(int index)
|
|||||||
return QByteArray((char *)extractCallbackSpec->data,extractCallbackSpec->newFileSize);
|
return QByteArray((char *)extractCallbackSpec->data,extractCallbackSpec->newFileSize);
|
||||||
}
|
}
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,12 @@ public slots:
|
|||||||
QList<QByteArray> getAllData(const QVector<quint32> & indexes, ExtractDelegate * delegate = 0);
|
QList<QByteArray> getAllData(const QVector<quint32> & indexes, ExtractDelegate * delegate = 0);
|
||||||
QByteArray getRawDataAtIndex(int index);
|
QByteArray getRawDataAtIndex(int index);
|
||||||
QList<QString> getFileNames();
|
QList<QString> getFileNames();
|
||||||
|
bool isValid();
|
||||||
private:
|
private:
|
||||||
SevenZipInterface * szInterface;
|
SevenZipInterface * szInterface;
|
||||||
QLibrary * sevenzLib;
|
QLibrary * sevenzLib;
|
||||||
void loadFunctions();
|
void loadFunctions();
|
||||||
|
bool valid;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user