@ -1626,7 +1626,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
@@ -1626,7 +1626,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
if ( append ) {
const qulonglong file_size = h . filesize_at ( i ) ;
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 " ) ) {
const QString new_name = name + " .!qB " ;
qDebug ( " Renaming %s to %s " , qPrintable ( name ) , qPrintable ( new_name ) ) ;
@ -1634,7 +1634,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
@@ -1634,7 +1634,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
}
}
} 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 " ) ) {
const QString old_name = name ;
name . chop ( 4 ) ;
@ -1927,7 +1927,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
@@ -1927,7 +1927,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
qDebug ( " Checking if the torrent contains torrent files to download " ) ;
// Check if there are torrent files inside
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 " ) ) {
qDebug ( " Found possible recursive torrent download. " ) ;
const QString torrent_fullpath = h . save_path ( ) + QDir : : separator ( ) + torrent_relpath ;
@ -1974,6 +1974,22 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
@@ -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 ( ) ) ) {
QTorrentHandle h ( p - > handle ) ;
if ( h . is_valid ( ) ) {
@ -2052,7 +2068,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
@@ -2052,7 +2068,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
else if ( file_completed_alert * p = dynamic_cast < file_completed_alert * > ( a . get ( ) ) ) {
QTorrentHandle h ( p - > handle ) ;
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 " ) ) {
const QString old_name = name ;
name . chop ( 4 ) ;