mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-31 17:04:34 +00:00
- Initial implementation of "Append .!qB extension to incomplete files" (untested)
- Update torrent save path when its label is changed and "Append label to save path" setting is set
This commit is contained in:
parent
1fd57b5d63
commit
c61aded388
@ -3,6 +3,7 @@
|
|||||||
- FEATURE: Labeled torrent can be downloaded corresponding subfolders
|
- FEATURE: Labeled torrent can be downloaded corresponding subfolders
|
||||||
- FEATURE: Disk cache size can be set from preferences
|
- FEATURE: Disk cache size can be set from preferences
|
||||||
- FEATURE: Peer Exchange (PeX) can be disabled from preferences
|
- FEATURE: Peer Exchange (PeX) can be disabled from preferences
|
||||||
|
- FEATURE: Append !.qB extension to incomplete files option (libtorrent >= v0.15 only)
|
||||||
|
|
||||||
* Thu Dec 10 2009 - Christophe Dumez <chris@qbittorrent.org> - v2.0.0
|
* Thu Dec 10 2009 - Christophe Dumez <chris@qbittorrent.org> - v2.0.0
|
||||||
- FEATURE: Added program option to disable splash screen
|
- FEATURE: Added program option to disable splash screen
|
||||||
|
@ -103,6 +103,9 @@ Bittorrent::Bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit
|
|||||||
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
|
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
|
||||||
connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
|
connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
|
||||||
appendLabelToSavePath = Preferences::appendTorrentLabel();
|
appendLabelToSavePath = Preferences::appendTorrentLabel();
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
appendqBExtension = Preferences::useIncompleteFilesExtension();
|
||||||
|
#endif
|
||||||
// Apply user settings to Bittorrent session
|
// Apply user settings to Bittorrent session
|
||||||
configureSession();
|
configureSession();
|
||||||
qDebug("* BTSession constructed");
|
qDebug("* BTSession constructed");
|
||||||
@ -235,6 +238,9 @@ void Bittorrent::configureSession() {
|
|||||||
setDefaultTempPath(QString::null);
|
setDefaultTempPath(QString::null);
|
||||||
}
|
}
|
||||||
setAppendLabelToSavePath(Preferences::appendTorrentLabel());
|
setAppendLabelToSavePath(Preferences::appendTorrentLabel());
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
setAppendqBExtension(Preferences::useIncompleteFilesExtension());
|
||||||
|
#endif
|
||||||
preAllocateAllFiles(Preferences::preAllocateAllFiles());
|
preAllocateAllFiles(Preferences::preAllocateAllFiles());
|
||||||
startTorrentsInPause(Preferences::addTorrentsInPause());
|
startTorrentsInPause(Preferences::addTorrentsInPause());
|
||||||
// * Scan dir
|
// * Scan dir
|
||||||
@ -935,6 +941,11 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
|||||||
qDebug("addTorrent: Saving save_path in persistent data: %s", savePath.toLocal8Bit().data());
|
qDebug("addTorrent: Saving save_path in persistent data: %s", savePath.toLocal8Bit().data());
|
||||||
TorrentPersistentData::saveSavePath(hash, savePath);
|
TorrentPersistentData::saveSavePath(hash, savePath);
|
||||||
}
|
}
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
// Append .!qB to incomplete files
|
||||||
|
if(appendqBExtension)
|
||||||
|
appendqBextensionToTorrent(h, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
QString newFile = torrentBackup.path() + QDir::separator() + hash + ".torrent";
|
QString newFile = torrentBackup.path() + QDir::separator() + hash + ".torrent";
|
||||||
if(file != newFile) {
|
if(file != newFile) {
|
||||||
@ -1281,6 +1292,52 @@ void Bittorrent::setDefaultTempPath(QString temppath) {
|
|||||||
defaultTempPath = temppath;
|
defaultTempPath = temppath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) {
|
||||||
|
if(!h.is_valid()) return;
|
||||||
|
std::vector<size_type> fp;
|
||||||
|
h.file_progress(fp);
|
||||||
|
for(int i=0; i<h.num_files(); ++i) {
|
||||||
|
if(append) {
|
||||||
|
if(fp[i] < 1.) {
|
||||||
|
QString name = h.file_at(i);
|
||||||
|
if(!name.endsWith(".!qB")) {
|
||||||
|
h.rename_file(i, name + ".!qB");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QString name = h.file_at(i);
|
||||||
|
if(name.endsWith(".!qB")) {
|
||||||
|
name.chop(4);
|
||||||
|
h.rename_file(i, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_label, QString new_label) {
|
||||||
|
if(!h.is_valid()) return;
|
||||||
|
if(!appendLabelToSavePath) return;
|
||||||
|
QString old_save_path = TorrentPersistentData::getSavePath(h.hash());
|
||||||
|
QDir old_dir(old_save_path);
|
||||||
|
bool move_storage = (old_dir == QDir(h.save_path()));
|
||||||
|
if(!old_label.isEmpty()) {
|
||||||
|
Q_ASSERT(old_dir.dirName() == old_label);
|
||||||
|
old_dir.cdUp();
|
||||||
|
}
|
||||||
|
QString new_save_path;
|
||||||
|
if(new_label.isEmpty())
|
||||||
|
new_save_path = old_dir.absolutePath();
|
||||||
|
else
|
||||||
|
old_dir.absoluteFilePath(new_label);
|
||||||
|
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
|
||||||
|
if(move_storage) {
|
||||||
|
// Move storage
|
||||||
|
h.move_storage(new_save_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
QString label = TorrentPersistentData::getLabel(h.hash());
|
QString label = TorrentPersistentData::getLabel(h.hash());
|
||||||
@ -1299,7 +1356,7 @@ void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::setAppendLabelToSavePath(bool append) {
|
void Bittorrent::setAppendLabelToSavePath(bool append) {
|
||||||
if(appendLabelToSavePath != Preferences::appendTorrentLabel()) {
|
if(appendLabelToSavePath != append) {
|
||||||
appendLabelToSavePath = !appendLabelToSavePath;
|
appendLabelToSavePath = !appendLabelToSavePath;
|
||||||
if(appendLabelToSavePath) {
|
if(appendLabelToSavePath) {
|
||||||
// Move torrents storage to sub folder with label name
|
// Move torrents storage to sub folder with label name
|
||||||
@ -1313,6 +1370,21 @@ void Bittorrent::setAppendLabelToSavePath(bool append) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
void Bittorrent::setAppendqBExtension(bool append) {
|
||||||
|
if(appendqBExtension != append) {
|
||||||
|
appendqBExtension = !appendqBExtension;
|
||||||
|
// append or remove .!qB extension for incomplete files
|
||||||
|
std::vector<torrent_handle> torrents = getTorrents();
|
||||||
|
std::vector<torrent_handle>::iterator torrentIT;
|
||||||
|
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
||||||
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
|
appendqBextensionToTorrent(h, appendqBExtension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Enable directory scanning
|
// Enable directory scanning
|
||||||
void Bittorrent::enableDirectoryScanning(QString scan_dir) {
|
void Bittorrent::enableDirectoryScanning(QString scan_dir) {
|
||||||
if(!scan_dir.isEmpty()) {
|
if(!scan_dir.isEmpty()) {
|
||||||
@ -1564,6 +1636,19 @@ void Bittorrent::readAlerts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
else if (file_completed_alert* p = dynamic_cast<file_completed_alert*>(a.get())) {
|
||||||
|
QTorrentHandle h(p->handle);
|
||||||
|
if(appendqBExtension) {
|
||||||
|
QString name = h.file_at(p->index);
|
||||||
|
if(name.endsWith(".!qB")) {
|
||||||
|
qDebug("File %s finished, removing .!qB extension", name.toLocal8Bit().data());
|
||||||
|
name.chop(4);
|
||||||
|
h.rename_file(p->index, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else if (listen_failed_alert* p = dynamic_cast<listen_failed_alert*>(a.get())) {
|
else if (listen_failed_alert* p = dynamic_cast<listen_failed_alert*>(a.get())) {
|
||||||
// Level: fatal
|
// Level: fatal
|
||||||
int tried_port = p->endpoint.port();
|
int tried_port = p->endpoint.port();
|
||||||
|
@ -110,6 +110,9 @@ private:
|
|||||||
bool PeXEnabled;
|
bool PeXEnabled;
|
||||||
bool queueingEnabled;
|
bool queueingEnabled;
|
||||||
bool appendLabelToSavePath;
|
bool appendLabelToSavePath;
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
bool appendqBExtension;
|
||||||
|
#endif
|
||||||
QString defaultSavePath;
|
QString defaultSavePath;
|
||||||
QString defaultTempPath;
|
QString defaultTempPath;
|
||||||
// GeoIP
|
// GeoIP
|
||||||
@ -202,6 +205,11 @@ public slots:
|
|||||||
void setDefaultTempPath(QString temppath);
|
void setDefaultTempPath(QString temppath);
|
||||||
void setAppendLabelToSavePath(bool append);
|
void setAppendLabelToSavePath(bool append);
|
||||||
void appendLabelToTorrentSavePath(QTorrentHandle h);
|
void appendLabelToTorrentSavePath(QTorrentHandle h);
|
||||||
|
void changeLabelInTorrentSavePath(QTorrentHandle h, QString old_label, QString new_label);
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
void appendqBextensionToTorrent(QTorrentHandle h, bool append);
|
||||||
|
void setAppendqBExtension(bool append);
|
||||||
|
#endif
|
||||||
void applyEncryptionSettings(pe_settings se);
|
void applyEncryptionSettings(pe_settings se);
|
||||||
void setDownloadLimit(QString hash, long val);
|
void setDownloadLimit(QString hash, long val);
|
||||||
void setUploadLimit(QString hash, long val);
|
void setUploadLimit(QString hash, long val);
|
||||||
|
@ -267,6 +267,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
|||||||
}
|
}
|
||||||
// Tab selection mecanism
|
// Tab selection mecanism
|
||||||
connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
|
connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
|
||||||
|
#ifndef LIBTORRENT_0_15
|
||||||
|
checkAppendqB->setVisible(false);
|
||||||
|
#endif
|
||||||
// Adapt size
|
// Adapt size
|
||||||
loadWindowState();
|
loadWindowState();
|
||||||
show();
|
show();
|
||||||
@ -372,7 +375,9 @@ void options_imp::saveOptions(){
|
|||||||
settings.setValue(QString::fromUtf8("TempPathEnabled"), isTempPathEnabled());
|
settings.setValue(QString::fromUtf8("TempPathEnabled"), isTempPathEnabled());
|
||||||
settings.setValue(QString::fromUtf8("TempPath"), getTempPath());
|
settings.setValue(QString::fromUtf8("TempPath"), getTempPath());
|
||||||
settings.setValue(QString::fromUtf8("AppendLabel"), checkAppendLabel->isChecked());
|
settings.setValue(QString::fromUtf8("AppendLabel"), checkAppendLabel->isChecked());
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked());
|
settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked());
|
||||||
|
#endif
|
||||||
settings.setValue(QString::fromUtf8("PreAllocation"), preAllocateAllFiles());
|
settings.setValue(QString::fromUtf8("PreAllocation"), preAllocateAllFiles());
|
||||||
settings.setValue(QString::fromUtf8("DiskCache"), spinCache->value());
|
settings.setValue(QString::fromUtf8("DiskCache"), spinCache->value());
|
||||||
settings.setValue(QString::fromUtf8("AdditionDialog"), useAdditionDialog());
|
settings.setValue(QString::fromUtf8("AdditionDialog"), useAdditionDialog());
|
||||||
@ -585,7 +590,9 @@ void options_imp::loadOptions(){
|
|||||||
}
|
}
|
||||||
textTempPath->setText(Preferences::getTempPath());
|
textTempPath->setText(Preferences::getTempPath());
|
||||||
checkAppendLabel->setChecked(Preferences::appendTorrentLabel());
|
checkAppendLabel->setChecked(Preferences::appendTorrentLabel());
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension());
|
checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension());
|
||||||
|
#endif
|
||||||
checkPreallocateAll->setChecked(Preferences::preAllocateAllFiles());
|
checkPreallocateAll->setChecked(Preferences::preAllocateAllFiles());
|
||||||
spinCache->setValue(Preferences::diskCacheSize());
|
spinCache->setValue(Preferences::diskCacheSize());
|
||||||
checkAdditionDialog->setChecked(Preferences::useAdditionDialog());
|
checkAdditionDialog->setChecked(Preferences::useAdditionDialog());
|
||||||
|
@ -133,10 +133,12 @@ public:
|
|||||||
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPath"), home+"qBT_dir"+QDir::separator()+"temp").toString();
|
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPath"), home+"qBT_dir"+QDir::separator()+"temp").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
static bool useIncompleteFilesExtension() {
|
static bool useIncompleteFilesExtension() {
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool();
|
return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool appendTorrentLabel() {
|
static bool appendTorrentLabel() {
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
@ -618,6 +618,10 @@ void QTorrentHandle::prioritize_first_last_piece(bool b) {
|
|||||||
h.piece_priority(last_piece, prio);
|
h.piece_priority(last_piece, prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QTorrentHandle::rename_file(int index, QString name) {
|
||||||
|
h.rename_file(index, name.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Operators
|
// Operators
|
||||||
//
|
//
|
||||||
|
@ -158,6 +158,7 @@ class QTorrentHandle {
|
|||||||
void set_peer_download_limit(libtorrent::asio::ip::tcp::endpoint ip, int limit) const;
|
void set_peer_download_limit(libtorrent::asio::ip::tcp::endpoint ip, int limit) const;
|
||||||
void add_tracker(announce_entry const& url);
|
void add_tracker(announce_entry const& url);
|
||||||
void prioritize_first_last_piece(bool b);
|
void prioritize_first_last_piece(bool b);
|
||||||
|
void rename_file(int index, QString name);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Operators
|
// Operators
|
||||||
|
@ -873,6 +873,8 @@ void TransferListWidget::setSelectionLabel(QString label) {
|
|||||||
proxyModel->setData(proxyModel->index(index.row(), TR_LABEL), QVariant(label));
|
proxyModel->setData(proxyModel->index(index.row(), TR_LABEL), QVariant(label));
|
||||||
TorrentPersistentData::saveLabel(hash, label);
|
TorrentPersistentData::saveLabel(hash, label);
|
||||||
emit torrentChangedLabel(old_label, label);
|
emit torrentChangedLabel(old_label, label);
|
||||||
|
// Update save path if necessary
|
||||||
|
BTSession->changeLabelInTorrentSavePath(BTSession->getTorrentHandle(hash), old_label, label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1132,7 +1132,7 @@ QGroupBox {
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>451</width>
|
<width>602</width>
|
||||||
<height>513</height>
|
<height>513</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user