mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added fix in order to avoid the creation of empty folders
This commit is contained in:
parent
430bd863dd
commit
9ce0da721e
@ -576,11 +576,11 @@ ComicDB DBHelper::loadComic(qulonglong id, QSqlDatabase & db)
|
|||||||
return comic;
|
return comic;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComicDB DBHelper::loadComic(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database)
|
ComicDB DBHelper::loadComic(QString cname, QString cpath, QString chash, QSqlDatabase & database)
|
||||||
{
|
{
|
||||||
ComicDB comic;
|
ComicDB comic;
|
||||||
|
|
||||||
comic.parentId = cparentId;
|
//comic.parentId = cparentId;
|
||||||
comic.name = cname;
|
comic.name = cname;
|
||||||
comic.path = cpath;
|
comic.path = cpath;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
//load
|
//load
|
||||||
static Folder loadFolder(qulonglong id, QSqlDatabase & db);
|
static Folder loadFolder(qulonglong id, QSqlDatabase & db);
|
||||||
static ComicDB loadComic(qulonglong id, QSqlDatabase & db);
|
static ComicDB loadComic(qulonglong id, QSqlDatabase & db);
|
||||||
static ComicDB loadComic(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
static ComicDB loadComic(QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
||||||
static ComicInfo loadComicInfo(QString hash, QSqlDatabase & db);
|
static ComicInfo loadComicInfo(QString hash, QSqlDatabase & db);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ qulonglong LibraryCreator::insertFolders()
|
|||||||
currentId = i->id;
|
currentId = i->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return currentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryCreator::create(QDir dir)
|
void LibraryCreator::create(QDir dir)
|
||||||
@ -217,10 +217,6 @@ bool LibraryCreator::checkCover(const QString & hash)
|
|||||||
|
|
||||||
void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo & fileInfo)
|
void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo & fileInfo)
|
||||||
{
|
{
|
||||||
//en este punto sabemos que todos los folders que hay en _currentPath, deberían estar añadidos a la base de datos
|
|
||||||
insertFolders();
|
|
||||||
emit(coverExtracted(relativePath));
|
|
||||||
|
|
||||||
//Se calcula el hash del cómic
|
//Se calcula el hash del cómic
|
||||||
|
|
||||||
QCryptographicHash crypto(QCryptographicHash::Sha1);
|
QCryptographicHash crypto(QCryptographicHash::Sha1);
|
||||||
@ -230,21 +226,26 @@ void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo &
|
|||||||
file.close();
|
file.close();
|
||||||
//hash Sha1 del primer 0.5MB + filesize
|
//hash Sha1 del primer 0.5MB + filesize
|
||||||
QString hash = QString(crypto.result().toHex().constData()) + QString::number(fileInfo.size());
|
QString hash = QString(crypto.result().toHex().constData()) + QString::number(fileInfo.size());
|
||||||
ComicDB comic = DBHelper::loadComic(_currentPathFolders.last().id,fileInfo.fileName(),relativePath,hash,_database);
|
ComicDB comic = DBHelper::loadComic(fileInfo.fileName(),relativePath,hash,_database);
|
||||||
int numPages = 0;
|
int numPages = 0;
|
||||||
|
|
||||||
if(! ( comic.hasCover() && checkCover(hash)))
|
if(! ( comic.hasCover() && checkCover(hash)))
|
||||||
{
|
{
|
||||||
ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+hash+".jpg",comic.info.coverPage.toInt());
|
ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+hash+".jpg",comic.info.coverPage.toInt());
|
||||||
//ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+fileInfo.fileName()+".jpg");
|
|
||||||
tc.create();
|
tc.create();
|
||||||
numPages = tc.getNumPages();
|
numPages = tc.getNumPages();
|
||||||
if (numPages > 0)
|
if (numPages > 0)
|
||||||
emit(comicAdded(relativePath,_target+"/covers/"+hash+".jpg"));
|
emit(comicAdded(relativePath,_target+"/covers/"+hash+".jpg"));
|
||||||
}
|
}
|
||||||
comic.info.numPages = numPages;
|
|
||||||
if (numPages > 0)
|
if (numPages > 0)
|
||||||
|
{
|
||||||
|
//en este punto sabemos que todos los folders que hay en _currentPath, deberían estar añadidos a la base de datos
|
||||||
|
insertFolders();
|
||||||
|
comic.info.numPages = numPages;
|
||||||
|
comic.parentId = _currentPathFolders.last().id;
|
||||||
DBHelper::insert(&comic,_database);
|
DBHelper::insert(&comic,_database);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryCreator::update(QDir dirS)
|
void LibraryCreator::update(QDir dirS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user