@ -1626,7 +1626,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
if ( append ) {
if ( append ) {
const qulonglong file_size = h . filesize_at ( i ) ;
const qulonglong file_size = h . filesize_at ( i ) ;
if ( file_size > 0 & & ( fp [ i ] / ( double ) file_size ) < 1. ) {
if ( file_size > 0 & & ( fp [ i ] / ( double ) file_size ) < 1. ) {
const QString & name = misc : : toQString ( h . get_torrent_info ( ) . file_at ( i ) . path . string ( ) ) ;
const QString & name = misc : : toQStringU ( h . get_torrent_info ( ) . file_at ( i ) . path . string ( ) ) ;
if ( ! name . endsWith ( " .!qB " ) ) {
if ( ! name . endsWith ( " .!qB " ) ) {
const QString new_name = name + " .!qB " ;
const QString new_name = name + " .!qB " ;
qDebug ( " Renaming %s to %s " , qPrintable ( name ) , qPrintable ( new_name ) ) ;
qDebug ( " Renaming %s to %s " , qPrintable ( name ) , qPrintable ( new_name ) ) ;
@ -1634,7 +1634,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
}
}
}
}
} else {
} else {
QString name = misc : : toQString ( h . get_torrent_info ( ) . file_at ( i ) . path . string ( ) ) ;
QString name = misc : : toQStringU ( h . get_torrent_info ( ) . file_at ( i ) . path . string ( ) ) ;
if ( name . endsWith ( " .!qB " ) ) {
if ( name . endsWith ( " .!qB " ) ) {
const QString old_name = name ;
const QString old_name = name ;
name . chop ( 4 ) ;
name . chop ( 4 ) ;
@ -1927,7 +1927,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
qDebug ( " Checking if the torrent contains torrent files to download " ) ;
qDebug ( " Checking if the torrent contains torrent files to download " ) ;
// Check if there are torrent files inside
// Check if there are torrent files inside
for ( int i = 0 ; i < h . get_torrent_info ( ) . num_files ( ) ; + + i ) {
for ( int i = 0 ; i < h . get_torrent_info ( ) . num_files ( ) ; + + i ) {
const QString & torrent_relpath = misc : : toQString ( h . get_torrent_info ( ) . file_at ( i ) . path . string ( ) ) ;
const QString & torrent_relpath = misc : : toQStringU ( h . get_torrent_info ( ) . file_at ( i ) . path . string ( ) ) ;
if ( torrent_relpath . endsWith ( " .torrent " ) ) {
if ( torrent_relpath . endsWith ( " .torrent " ) ) {
qDebug ( " Found possible recursive torrent download. " ) ;
qDebug ( " Found possible recursive torrent download. " ) ;
const QString torrent_fullpath = h . save_path ( ) + QDir : : separator ( ) + torrent_relpath ;
const QString torrent_fullpath = h . save_path ( ) + QDir : : separator ( ) + torrent_relpath ;
@ -1974,6 +1974,22 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
}
}
}
}
}
}
else if ( file_renamed_alert * p = dynamic_cast < file_renamed_alert * > ( a . get ( ) ) ) {
QTorrentHandle h ( p - > handle ) ;
if ( h . is_valid ( ) & & h . num_files ( ) > 1 ) {
// Check if folders were renamed
QStringList old_path_parts = misc : : toQStringU ( h . get_torrent_info ( ) . orig_files ( ) . at ( p - > index ) . path . string ( ) ) . split ( " / " ) ;
old_path_parts . removeLast ( ) ;
QString old_path = old_path_parts . join ( " / " ) ;
QStringList new_path_parts = misc : : toQStringU ( p - > name ) . split ( " / " ) ;
new_path_parts . removeLast ( ) ;
if ( old_path ! = new_path_parts . join ( " / " ) ) {
old_path = h . save_path ( ) + " / " + old_path ;
qDebug ( " Detected folder renaming, attempt to delete old folder: %s " , qPrintable ( old_path ) ) ;
QDir ( ) . rmpath ( old_path ) ;
}
}
}
else if ( storage_moved_alert * p = dynamic_cast < storage_moved_alert * > ( a . get ( ) ) ) {
else if ( storage_moved_alert * p = dynamic_cast < storage_moved_alert * > ( a . get ( ) ) ) {
QTorrentHandle h ( p - > handle ) ;
QTorrentHandle h ( p - > handle ) ;
if ( h . is_valid ( ) ) {
if ( h . is_valid ( ) ) {
@ -2052,7 +2068,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
else if ( file_completed_alert * p = dynamic_cast < file_completed_alert * > ( a . get ( ) ) ) {
else if ( file_completed_alert * p = dynamic_cast < file_completed_alert * > ( a . get ( ) ) ) {
QTorrentHandle h ( p - > handle ) ;
QTorrentHandle h ( p - > handle ) ;
if ( appendqBExtension ) {
if ( appendqBExtension ) {
QString name = misc : : toQString ( h . get_torrent_info ( ) . file_at ( p - > index ) . path . string ( ) ) ;
QString name = misc : : toQStringU ( h . get_torrent_info ( ) . file_at ( p - > index ) . path . string ( ) ) ;
if ( name . endsWith ( " .!qB " ) ) {
if ( name . endsWith ( " .!qB " ) ) {
const QString old_name = name ;
const QString old_name = name ;
name . chop ( 4 ) ;
name . chop ( 4 ) ;