mirror of
https://github.com/martravi/wiiqt6.git
synced 2024-11-22 21:29:15 +01:00
*nusDownloader:: fix cache bug caused be overzealous optimizations; add better error handeling when reading and saving data to/fromcache
*ohneschwanzenegger:: change possible misleading version text when overwriting a title git-svn-id: http://wiiqt.googlecode.com/svn/trunk@96 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
parent
ad906d24d9
commit
2777708318
@ -48,6 +48,7 @@ bool NandBin::SetPath( const QString &path )
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString NandBin::FilePath()
|
const QString NandBin::FilePath()
|
||||||
{
|
{
|
||||||
if( !f.isOpen() )
|
if( !f.isOpen() )
|
||||||
@ -55,7 +56,6 @@ const QString NandBin::FilePath()
|
|||||||
return QFileInfo( f ).absoluteFilePath();
|
return QFileInfo( f ).absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
//#if 0 // apparently you dont need any extra reserved blocks for the thing to boot?
|
|
||||||
bool NandBin::CreateNew( const QString &path, const QByteArray &keys, const QByteArray &first8, const QList<quint16> &badBlocks )
|
bool NandBin::CreateNew( const QString &path, const QByteArray &keys, const QByteArray &first8, const QList<quint16> &badBlocks )
|
||||||
{
|
{
|
||||||
#ifndef NAND_BIN_CAN_WRITE
|
#ifndef NAND_BIN_CAN_WRITE
|
||||||
@ -158,7 +158,6 @@ bool NandBin::CreateNew( const QString &path, const QByteArray &keys, const QByt
|
|||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
|
|
||||||
bool NandBin::Format( bool secure )
|
bool NandBin::Format( bool secure )
|
||||||
{
|
{
|
||||||
@ -1344,7 +1343,7 @@ bool NandBin::DeleteItem( QTreeWidgetItem *item )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "NandBin::DeleteItem" << item->text( 0 );
|
//qDebug() << "NandBin::DeleteItem" << item->text( 0 );
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
quint16 idx = item->text( 1 ).toInt( &ok );//get the index of the entry to remove
|
quint16 idx = item->text( 1 ).toInt( &ok );//get the index of the entry to remove
|
||||||
if( !ok || idx > 0x17fe )
|
if( !ok || idx > 0x17fe )
|
||||||
@ -1428,7 +1427,7 @@ bool NandBin::DeleteItem( QTreeWidgetItem *item )
|
|||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
//int q = 0;
|
//int q = 0;
|
||||||
qDebug() << "deleting clusters of" << item->text( 0 ) << idx;
|
//qDebug() << "deleting clusters of" << item->text( 0 ) << idx;
|
||||||
QList<quint16> toFree = GetFatsForFile( idx );
|
QList<quint16> toFree = GetFatsForFile( idx );
|
||||||
foreach( quint16 cl, toFree )
|
foreach( quint16 cl, toFree )
|
||||||
{
|
{
|
||||||
|
@ -126,7 +126,19 @@ QByteArray NusDownloader::GetDataFromCache( const downloadJob &job )
|
|||||||
}
|
}
|
||||||
|
|
||||||
QFile f( GetCachePath( job.index ) );
|
QFile f( GetCachePath( job.index ) );
|
||||||
if( !f.exists() || !f.open( QIODevice::ReadOnly ) )
|
if( !f.exists() )
|
||||||
|
{
|
||||||
|
//qWarning() << "NusDownloader::GetDataFromCache -> file doesnt exist" << QFileInfo( f ).absoluteFilePath();
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
if( !f.size() )
|
||||||
|
{
|
||||||
|
f.remove();
|
||||||
|
qWarning() << "NusDownloader::GetDataFromCache -> file was 0 bytes" << QFileInfo( f ).absoluteFilePath();
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !f.open( QIODevice::ReadOnly ) )
|
||||||
{
|
{
|
||||||
//qWarning() << "NusDownloader::GetDataFromCache -> file cant be opened for reading" << QFileInfo( f ).absoluteFilePath();
|
//qWarning() << "NusDownloader::GetDataFromCache -> file cant be opened for reading" << QFileInfo( f ).absoluteFilePath();
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
@ -178,7 +190,7 @@ void NusDownloader::ReadTmdAndGetTicket( const QByteArray &ba )
|
|||||||
if( stuff.isEmpty() )
|
if( stuff.isEmpty() )
|
||||||
{
|
{
|
||||||
dlJob = tikJob;
|
dlJob = tikJob;
|
||||||
QTimer::singleShot( 0, this, SLOT( StartDownload() ) );
|
QTimer::singleShot( 50, this, SLOT( StartDownload() ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -188,13 +200,20 @@ void NusDownloader::ReadTmdAndGetTicket( const QByteArray &ba )
|
|||||||
//AesSetKey( t.DecryptedKey() );
|
//AesSetKey( t.DecryptedKey() );
|
||||||
//add the ticket data to the return
|
//add the ticket data to the return
|
||||||
currentJob.data << stuff;
|
currentJob.data << stuff;
|
||||||
QTimer::singleShot( 0, this, SLOT( GetNextItemForCurrentTitle() ) );
|
QTimer::singleShot( 50, this, SLOT( GetNextItemForCurrentTitle() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//save data downloaded from the internet to local HDD for future downloads
|
//save data downloaded from the internet to local HDD for future downloads
|
||||||
bool NusDownloader::SaveDataToCache( const QString &path, const QByteArray &stuff )
|
bool NusDownloader::SaveDataToCache( const QString &path, const QByteArray &stuff )
|
||||||
{
|
{
|
||||||
|
//qDebug() << "NusDownloader::SaveDataToCache ->" << path;
|
||||||
|
if( !stuff.size() )
|
||||||
|
{
|
||||||
|
qWarning() << "NusDownloader::SaveDataToCache -> !size" << path;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//make sure there is all the parent folders needed to hold this folder
|
//make sure there is all the parent folders needed to hold this folder
|
||||||
if( path.count( "/" ) < 4 || !path.startsWith( cachePath + "/" ))
|
if( path.count( "/" ) < 4 || !path.startsWith( cachePath + "/" ))
|
||||||
{
|
{
|
||||||
@ -219,9 +238,16 @@ bool NusDownloader::SaveDataToCache( const QString &path, const QByteArray &stuf
|
|||||||
qWarning() << "NusDownloader::SaveDataToCache -> can't create file" << path;
|
qWarning() << "NusDownloader::SaveDataToCache -> can't create file" << path;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
f.write( stuff );//probably should check the return values on these. but if they dont go right, then the person has bigger things to worry about
|
if( f.write( stuff ) != stuff.size() )
|
||||||
|
{
|
||||||
|
f.close();
|
||||||
|
f.remove();
|
||||||
|
qWarning() << "NusDownloader::SaveDataToCache -> error writing data to" << path;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
f.flush();
|
||||||
f.close();
|
f.close();
|
||||||
qDebug() << "saved" << hex << stuff.size() << "bytes to" << path;
|
//qDebug() << "saved" << hex << stuff.size() << "bytes to" << path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +266,7 @@ void NusDownloader::CurrentJobErrored( const QString &str )
|
|||||||
{
|
{
|
||||||
qWarning() << "NusDownloader::CurrentJobErrored ->" << str;
|
qWarning() << "NusDownloader::CurrentJobErrored ->" << str;
|
||||||
emit SendError( str, currentJob );
|
emit SendError( str, currentJob );
|
||||||
QTimer::singleShot( 0, this, SLOT( StartNextJob() ) );
|
QTimer::singleShot( 50, this, SLOT( StartNextJob() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the next content for the current title
|
//get the next content for the current title
|
||||||
@ -286,7 +312,7 @@ void NusDownloader::GetNextItemForCurrentTitle()
|
|||||||
}
|
}
|
||||||
//qDebug() << "hash matched for index" << alreadyHave;
|
//qDebug() << "hash matched for index" << alreadyHave;
|
||||||
if( alreadyHave + 1 < qFromBigEndian( curTmd.payload()->num_contents ) )
|
if( alreadyHave + 1 < qFromBigEndian( curTmd.payload()->num_contents ) )
|
||||||
QTimer::singleShot( 0, this, SLOT( GetNextItemForCurrentTitle() ) );//next content
|
QTimer::singleShot( 50, this, SLOT( GetNextItemForCurrentTitle() ) );//next content
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -294,7 +320,7 @@ void NusDownloader::GetNextItemForCurrentTitle()
|
|||||||
emit SendTotalProgress( progress );
|
emit SendTotalProgress( progress );
|
||||||
emit SendTitleProgress( 100 );
|
emit SendTitleProgress( 100 );
|
||||||
emit SendData( currentJob );
|
emit SendData( currentJob );
|
||||||
QTimer::singleShot( 0, this, SLOT( StartNextJob() ) );//start next job
|
QTimer::singleShot( 50, this, SLOT( StartNextJob() ) );//start next job
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,7 +397,7 @@ bool NusDownloader::DecryptCheckHashAndAppendData( const QByteArray &encData, qu
|
|||||||
}
|
}
|
||||||
|
|
||||||
//something is done downloading
|
//something is done downloading
|
||||||
void NusDownloader::FileIsFinishedDownloading( const downloadJob &job )
|
void NusDownloader::FileIsFinishedDownloading( downloadJob job )
|
||||||
{
|
{
|
||||||
//qDebug() << "NusDownloader::FileIsFinishedDownloading" << job.index;
|
//qDebug() << "NusDownloader::FileIsFinishedDownloading" << job.index;
|
||||||
if( job.data.isEmpty() )
|
if( job.data.isEmpty() )
|
||||||
@ -401,7 +427,8 @@ void NusDownloader::FileIsFinishedDownloading( const downloadJob &job )
|
|||||||
//add the ticket data to the return
|
//add the ticket data to the return
|
||||||
currentJob.data << job.data;
|
currentJob.data << job.data;
|
||||||
//start downloading the contents
|
//start downloading the contents
|
||||||
GetNextItemForCurrentTitle();
|
//GetNextItemForCurrentTitle();
|
||||||
|
QTimer::singleShot( 50, this, SLOT( GetNextItemForCurrentTitle() ) );//next content
|
||||||
|
|
||||||
cPath = GetCachePath( job.index );
|
cPath = GetCachePath( job.index );
|
||||||
}
|
}
|
||||||
@ -433,11 +460,11 @@ void NusDownloader::FileIsFinishedDownloading( const downloadJob &job )
|
|||||||
emit SendTotalProgress( progress );
|
emit SendTotalProgress( progress );
|
||||||
emit SendTitleProgress( 100 );
|
emit SendTitleProgress( 100 );
|
||||||
emit SendData( currentJob );
|
emit SendData( currentJob );
|
||||||
QTimer::singleShot( 0, this, SLOT( StartNextJob() ) );//move on to next job
|
QTimer::singleShot( 50, this, SLOT( StartNextJob() ) );//move on to next job
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
QTimer::singleShot( 0, this, SLOT( GetNextItemForCurrentTitle() ) );//next content
|
QTimer::singleShot( 50, this, SLOT( GetNextItemForCurrentTitle() ) );//next content
|
||||||
|
|
||||||
cPath = GetCachePath( job.index );
|
cPath = GetCachePath( job.index );
|
||||||
}
|
}
|
||||||
@ -457,7 +484,7 @@ void NusDownloader::StartDownload()
|
|||||||
//qDebug() << "NusDownloader::StartDownload" << dlJob.index;
|
//qDebug() << "NusDownloader::StartDownload" << dlJob.index;
|
||||||
emit SendDownloadProgress( 0 );
|
emit SendDownloadProgress( 0 );
|
||||||
QString dlUrl = NUS_BASE_URL + dlJob.tid + "/" + dlJob.name;
|
QString dlUrl = NUS_BASE_URL + dlJob.tid + "/" + dlJob.name;
|
||||||
qDebug() << "url" << dlUrl;
|
//qDebug() << "url" << dlUrl;
|
||||||
currentJobText = dlUrl;
|
currentJobText = dlUrl;
|
||||||
|
|
||||||
QUrl url( dlUrl );
|
QUrl url( dlUrl );
|
||||||
|
@ -121,7 +121,9 @@ private:
|
|||||||
bool DecryptCheckHashAndAppendData( const QByteArray &encData, quint16 idx );
|
bool DecryptCheckHashAndAppendData( const QByteArray &encData, quint16 idx );
|
||||||
|
|
||||||
//triggered when a file is done downloading
|
//triggered when a file is done downloading
|
||||||
void FileIsFinishedDownloading( const downloadJob &job );
|
//! dont use const reference here, as the job is really a variable which is reused
|
||||||
|
//! for every download
|
||||||
|
void FileIsFinishedDownloading( downloadJob job );
|
||||||
|
|
||||||
//send a fail message about the current job and skip to the next
|
//send a fail message about the current job and skip to the next
|
||||||
void CurrentJobErrored( const QString &str );
|
void CurrentJobErrored( const QString &str );
|
||||||
|
@ -685,7 +685,7 @@ bool MainWindow::InstallNUSItem( NusJob job )
|
|||||||
{
|
{
|
||||||
//nand.WriteMetaData();
|
//nand.WriteMetaData();
|
||||||
UpdateTree();
|
UpdateTree();
|
||||||
ShowMessage( tr( "Deleted old TMD and private contents for<br>%1" ).arg( title ) );
|
ShowMessage( tr( "Deleted old TMD and private contents for<br>%1" ).arg( job.tid, 16, 16, QChar( '0' ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = t.Count();
|
cnt = t.Count();
|
||||||
@ -982,7 +982,7 @@ void MainWindow::on_actionFormat_triggered()
|
|||||||
//wipe all user-created entries from uid.sys
|
//wipe all user-created entries from uid.sys
|
||||||
QByteArray uidData = uid.Data();
|
QByteArray uidData = uid.Data();
|
||||||
QBuffer buf( &uidData );
|
QBuffer buf( &uidData );
|
||||||
buf.open( QIODevice::ReadWrite );
|
buf.open( QIODevice::ReadOnly );
|
||||||
|
|
||||||
quint64 tid;
|
quint64 tid;
|
||||||
quint16 titles = 0;
|
quint16 titles = 0;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "../WiiQt/uidmap.h"
|
#include "../WiiQt/uidmap.h"
|
||||||
#include "../WiiQt/tools.h"
|
#include "../WiiQt/tools.h"
|
||||||
|
|
||||||
NewNandBin::NewNandBin( QWidget *parent, QList<quint16> badBlocks ) : QDialog(parent), ui(new Ui::NewNandBin), nand( this )
|
NewNandBin::NewNandBin( QWidget *parent, const QList<quint16> &badBlocks ) : QDialog(parent), ui(new Ui::NewNandBin), nand( this )
|
||||||
{
|
{
|
||||||
dir = QDir::currentPath();
|
dir = QDir::currentPath();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -204,7 +204,7 @@ void NewNandBin::on_buttonBox_accepted()
|
|||||||
ret = ui->lineEdit_dest->text();
|
ret = ui->lineEdit_dest->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NewNandBin::GetNewNandPath( QWidget *parent, QList<quint16> badBlocks )
|
QString NewNandBin::GetNewNandPath( QWidget *parent, const QList<quint16> &badBlocks )
|
||||||
{
|
{
|
||||||
NewNandBin d( parent, badBlocks );
|
NewNandBin d( parent, badBlocks );
|
||||||
if( !d.exec() )
|
if( !d.exec() )
|
||||||
@ -339,7 +339,7 @@ void NewNandBin::on_pushButton_oldNand_clicked()
|
|||||||
QByteArray NewNandBin::GetCleanUid( QByteArray old )
|
QByteArray NewNandBin::GetCleanUid( QByteArray old )
|
||||||
{
|
{
|
||||||
QBuffer buf( &old );
|
QBuffer buf( &old );
|
||||||
buf.open( QIODevice::ReadWrite );
|
buf.open( QIODevice::ReadOnly );
|
||||||
|
|
||||||
quint64 tid;
|
quint64 tid;
|
||||||
quint16 titles = 0;
|
quint16 titles = 0;
|
||||||
|
@ -13,10 +13,10 @@ class NewNandBin : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NewNandBin( QWidget *parent = 0, QList<quint16>badBlocks = QList<quint16>() );
|
explicit NewNandBin( QWidget *parent = 0, const QList<quint16> &badBlocks = QList<quint16>() );
|
||||||
~NewNandBin();
|
~NewNandBin();
|
||||||
|
|
||||||
static QString GetNewNandPath( QWidget *parent = 0, QList<quint16>badBlocks = QList<quint16>() );
|
static QString GetNewNandPath( QWidget *parent = 0, const QList<quint16> &badBlocks = QList<quint16>() );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NewNandBin *ui;
|
Ui::NewNandBin *ui;
|
||||||
@ -32,7 +32,7 @@ private:
|
|||||||
QByteArray uidSys;
|
QByteArray uidSys;
|
||||||
|
|
||||||
bool CreateDefaultEntries();
|
bool CreateDefaultEntries();
|
||||||
QByteArray GetCleanUid( QByteArray old );
|
QByteArray GetCleanUid( QByteArray old );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_oldNand_clicked();
|
void on_pushButton_oldNand_clicked();
|
||||||
|
Loading…
Reference in New Issue
Block a user