mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 05:48:47 +03:00
Make possible to move file to .unwanted directory after downloading
This commit is contained in:
parent
a77be2f6ce
commit
4ec176b683
1 changed files with 13 additions and 14 deletions
|
@ -713,22 +713,21 @@ void QTorrentHandle::prioritize_files(const vector<int> &files) const {
|
||||||
file_progress(progress);
|
file_progress(progress);
|
||||||
qDebug() << Q_FUNC_INFO << "Changing files priorities...";
|
qDebug() << Q_FUNC_INFO << "Changing files priorities...";
|
||||||
torrent_handle::prioritize_files(files);
|
torrent_handle::prioritize_files(files);
|
||||||
qDebug() << Q_FUNC_INFO << "Moving unwanted files to .unwanted folder...";
|
qDebug() << Q_FUNC_INFO << "Moving unwanted files to .unwanted folder and conversely...";
|
||||||
for (uint i = 0; i < files.size(); ++i) {
|
for (uint i = 0; i < files.size(); ++i) {
|
||||||
// Move unwanted files to a .unwanted subfolder
|
// Move unwanted files to a .unwanted subfolder
|
||||||
if (files[i] == 0 && progress[i] < filesize_at(i)) {
|
if (files[i] == 0) {
|
||||||
QString old_path = filepath_at(i);
|
QString old_abspath = QDir(save_path()).absoluteFilePath(filepath_at(i));
|
||||||
|
QString parent_abspath = fsutils::branchPath(old_abspath);
|
||||||
// Make sure the file does not already exists
|
// Make sure the file does not already exists
|
||||||
if (QFile::exists(QDir(save_path()).absoluteFilePath(old_path))) {
|
if (QDir(parent_abspath).dirName() != ".unwanted") {
|
||||||
qWarning() << "File" << old_path << "already exists at destination.";
|
QString unwanted_abspath = parent_abspath+"/.unwanted";
|
||||||
qWarning() << "We do not move it to .unwanted folder";
|
QString new_abspath = unwanted_abspath+"/"+filename_at(i);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
QString old_name = filename_at(i);
|
|
||||||
QString parent_path = fsutils::branchPath(old_path);
|
|
||||||
if (parent_path.isEmpty() || QDir(parent_path).dirName() != ".unwanted") {
|
|
||||||
QString unwanted_abspath = QDir::cleanPath(save_path()+"/"+parent_path+"/.unwanted");
|
|
||||||
qDebug() << "Unwanted path is" << unwanted_abspath;
|
qDebug() << "Unwanted path is" << unwanted_abspath;
|
||||||
|
if (QFile::exists(new_abspath)) {
|
||||||
|
qWarning() << "File" << new_abspath << "already exists at destination.";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bool created = QDir().mkpath(unwanted_abspath);
|
bool created = QDir().mkpath(unwanted_abspath);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
qDebug() << "unwanted folder was created:" << created;
|
qDebug() << "unwanted folder was created:" << created;
|
||||||
|
@ -743,13 +742,13 @@ void QTorrentHandle::prioritize_files(const vector<int> &files) const {
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(created);
|
Q_UNUSED(created);
|
||||||
#endif
|
#endif
|
||||||
|
QString parent_path = fsutils::branchPath(filepath_at(i));
|
||||||
if (!parent_path.isEmpty() && !parent_path.endsWith("/"))
|
if (!parent_path.isEmpty() && !parent_path.endsWith("/"))
|
||||||
parent_path += "/";
|
parent_path += "/";
|
||||||
rename_file(i, parent_path+".unwanted/"+old_name);
|
rename_file(i, parent_path+".unwanted/"+filename_at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Move wanted files back to their original folder
|
// Move wanted files back to their original folder
|
||||||
qDebug() << Q_FUNC_INFO << "Moving wanted files back from .unwanted folder";
|
|
||||||
if (files[i] > 0) {
|
if (files[i] > 0) {
|
||||||
QString parent_relpath = fsutils::branchPath(filepath_at(i));
|
QString parent_relpath = fsutils::branchPath(filepath_at(i));
|
||||||
if (QDir(parent_relpath).dirName() == ".unwanted") {
|
if (QDir(parent_relpath).dirName() == ".unwanted") {
|
||||||
|
|
Loading…
Reference in a new issue