Skip to content

Commit ec2b417

Browse files
committed
Revamp .torrent files backup management
1 parent 5a07050 commit ec2b417

17 files changed

Lines changed: 944 additions & 196 deletions

WebAPI_Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
* [#24135](https://github.com/qbittorrent/qBittorrent/pull/24135)
3030
* Add `torrents/downloadFile` endpoint with `hash` and `file` as parameters allowing to download a completed file from torrent content
3131
* `file` accepts either file index or path relative to content root
32+
* [#24641](https://github.com/qbittorrent/qBittorrent/pull/24641)
33+
* `app/preferences` and `app/setPreferences` endpoints no longer include `export_dir` and `export_dir_fin` options as they are no longer supported by the core
34+
* `app/preferences` and `app/setPreferences` endpoints include the following new options:
35+
* `torrent_files_backup_enabled` (bool) - enable/disable saving backup copies of .torrent files
36+
* `torrent_files_backup_dir` (string) - the folder path for saving backup copies of .torrent files
37+
* `torrent_files_finished_backup_dir` (bool) - enable/disable moving backup copies of .torrent files to another folder when torrent is finished
38+
* `torrent_files_finished_backup_dir` (string) - the folder path for moving backup copies of .torrent files when torrent is finished
39+
* `remove_torrent_file_backup` (bool) - whether .torrent file backup should be removed when removing the torrent
3240

3341
## 2.15.4
3442

src/app/upgrade.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ using namespace Qt::Literals::StringLiterals;
4848

4949
namespace
5050
{
51-
const int MIGRATION_VERSION = 10;
51+
const int MIGRATION_VERSION = 11;
5252
const QString MIGRATION_VERSION_KEY = u"Meta/MigrationVersion"_s;
5353

5454
void exportWebUIHttpsFiles()
@@ -557,6 +557,22 @@ namespace
557557
if (!settingsStorage->hasKey(key))
558558
SettingsStorage::instance()->storeValue(key, true);
559559
}
560+
561+
void migrateTorrentExportFolderSettings()
562+
{
563+
const auto doMigrate = [](const QString &oldKey, const QString &newKey)
564+
{
565+
auto *settingsStorage = SettingsStorage::instance();
566+
if (settingsStorage->hasKey(oldKey))
567+
{
568+
settingsStorage->storeValue(newKey, settingsStorage->loadValue<Path>(oldKey));
569+
settingsStorage->removeValue(oldKey);
570+
}
571+
};
572+
573+
doMigrate(u"BitTorrent/Session/TorrentExportDirectory"_s, u"BitTorrent/Session/TorrentBackupDirectory"_s);
574+
doMigrate(u"BitTorrent/Session/FinishedTorrentExportDirectory"_s, u"BitTorrent/Session/FinishedTorrentBackupDirectory"_s);
575+
}
560576
}
561577

562578
bool upgrade()
@@ -609,6 +625,9 @@ bool upgrade()
609625
setResolvePeerCountriesSetting();
610626
}
611627

628+
if (version < 11)
629+
migrateTorrentExportFolderSettings();
630+
612631
version = MIGRATION_VERSION;
613632
}
614633

src/base/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ add_library(qbt_base STATIC
7171
http/server.h
7272
indexrange.h
7373
interfaces/iapplication.h
74+
keyvaluedatastorage.h
7475
logger.h
7576
net/dnsupdater.h
7677
net/downloadhandlerimpl.h
@@ -174,6 +175,7 @@ add_library(qbt_base STATIC
174175
http/requestparser.cpp
175176
http/responsewriterimpl.cpp
176177
http/server.cpp
178+
keyvaluedatastorage.cpp
177179
logger.cpp
178180
net/dnsupdater.cpp
179181
net/downloadhandlerimpl.cpp

src/base/bittorrent/session.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,17 @@ namespace BitTorrent
230230
virtual void setRefreshInterval(int value) = 0;
231231
virtual bool isPreallocationEnabled() const = 0;
232232
virtual void setPreallocationEnabled(bool enabled) = 0;
233-
virtual Path torrentExportDirectory() const = 0;
234-
virtual void setTorrentExportDirectory(const Path &path) = 0;
235-
virtual Path finishedTorrentExportDirectory() const = 0;
236-
virtual void setFinishedTorrentExportDirectory(const Path &path) = 0;
233+
234+
virtual bool isTorrentFileBackupEnabled() const = 0;
235+
virtual void setTorrentFileBackupEnabled(bool enabled) = 0;
236+
virtual Path torrentBackupDirectory() const = 0;
237+
virtual void setTorrentBackupDirectory(const Path &path) = 0;
238+
virtual bool isFinishedTorrentBackupDirectoryEnabled() const = 0;
239+
virtual void setFinishedTorrentBackupDirectoryEnabled(bool enabled) = 0;
240+
virtual Path finishedTorrentBackupDirectory() const = 0;
241+
virtual void setFinishedTorrentBackupDirectory(const Path &path) = 0;
242+
virtual bool removeTorrentFileBackup() const = 0;
243+
virtual void setRemoveTorrentFileBackup(bool remove) = 0;
237244

238245
virtual bool isAddTrackersFromURLEnabled() const = 0;
239246
virtual void setAddTrackersFromURLEnabled(bool enabled) = 0;

0 commit comments

Comments
 (0)