mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Reenable bootstrapping of torrent DHTs
Enable setting of overwrite settings for download files
This commit is contained in:
@@ -119,7 +119,11 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
|
||||
}
|
||||
_session->start_upnp();
|
||||
_session->start_dht();
|
||||
|
||||
|
||||
_session->add_dht_router({ "dht.transmissionbt.com", 6881});
|
||||
_session->add_dht_router({ "router.bittorrent.com", 6881});
|
||||
_session->add_dht_router({ "router.utorrent.com", 6881 });
|
||||
_session->add_dht_router({ "router.bitcomet.com", 6881 });
|
||||
|
||||
QTimer* timer = new QTimer(this);
|
||||
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(handleTimer()));
|
||||
@@ -160,17 +164,21 @@ void SyncWidget::clear() {
|
||||
void SyncWidget::handleDirectFiles() {
|
||||
qDebug() << "Direct Files";
|
||||
for (const DirectFile& f : _directFiles) {
|
||||
InfoWidget* w = new InfoWidget(f.destination);
|
||||
_downloadLayout->addWidget(w);
|
||||
|
||||
qDebug() << f.url << " -> " << f.destination;
|
||||
|
||||
openspace::DownloadManager::FileFuture* future = DlManager.downloadFile(
|
||||
f.url.toStdString(),
|
||||
fullPath(f.module, f.destination).toStdString()
|
||||
fullPath(f.module, f.destination).toStdString(),
|
||||
false
|
||||
);
|
||||
_futures.push_back(future);
|
||||
_futureInfoWidgetMap[future] = w;
|
||||
if (future) {
|
||||
InfoWidget* w = new InfoWidget(f.destination);
|
||||
_downloadLayout->addWidget(w);
|
||||
|
||||
_futures.push_back(future);
|
||||
_futureInfoWidgetMap[future] = w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +194,8 @@ void SyncWidget::handleFileRequest() {
|
||||
DlManager.downloadRequestFiles(
|
||||
identifier,
|
||||
path,
|
||||
version
|
||||
version,
|
||||
false
|
||||
);
|
||||
|
||||
_futures.insert(_futures.end(), futures.begin(), futures.end());
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
FileFuture* downloadFile(
|
||||
const std::string& url,
|
||||
const ghoul::filesystem::File& file,
|
||||
bool overrideFile = true,
|
||||
DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(),
|
||||
DownloadProgressCallback progressCallback = DownloadProgressCallback()
|
||||
);
|
||||
@@ -65,6 +66,7 @@ public:
|
||||
const std::string& identifier,
|
||||
const ghoul::filesystem::Directory& destination,
|
||||
int version,
|
||||
bool overrideFiles = true,
|
||||
DownloadFinishedCallback finishedCallback = DownloadFinishedCallback(),
|
||||
DownloadProgressCallback progressCallback = DownloadProgressCallback()
|
||||
);
|
||||
|
||||
@@ -106,9 +106,13 @@ DownloadManager::DownloadManager(std::string requestURL, int applicationVersion)
|
||||
DownloadManager::FileFuture* DownloadManager::downloadFile(
|
||||
const std::string& url,
|
||||
const ghoul::filesystem::File& file,
|
||||
bool overrideFile,
|
||||
DownloadFinishedCallback finishedCallback,
|
||||
DownloadProgressCallback progressCallback)
|
||||
{
|
||||
if (!overrideFile && FileSys.fileExists(file))
|
||||
return nullptr;
|
||||
|
||||
FileFuture* future = new FileFuture(
|
||||
file.filename()
|
||||
);
|
||||
@@ -154,6 +158,7 @@ std::vector<DownloadManager::FileFuture*> DownloadManager::downloadRequestFiles(
|
||||
const std::string& identifier,
|
||||
const ghoul::filesystem::Directory& destination,
|
||||
int version,
|
||||
bool overrideFiles,
|
||||
DownloadFinishedCallback finishedCallback,
|
||||
DownloadProgressCallback progressCallback)
|
||||
{
|
||||
@@ -171,7 +176,7 @@ std::vector<DownloadManager::FileFuture*> DownloadManager::downloadRequestFiles(
|
||||
LDEBUG("Request File: " << requestFile);
|
||||
|
||||
bool isFinished = false;
|
||||
auto callback = [&futures, destination, &progressCallback, &isFinished, requestFile](const FileFuture& f) {
|
||||
auto callback = [&futures, destination, &progressCallback, &isFinished, requestFile, overrideFiles](const FileFuture& f) {
|
||||
LDEBUG("Finished: " << requestFile);
|
||||
std::ifstream temporary(requestFile);
|
||||
std::string line;
|
||||
@@ -185,9 +190,11 @@ std::vector<DownloadManager::FileFuture*> DownloadManager::downloadRequestFiles(
|
||||
|
||||
FileFuture* future = DlManager.downloadFile(
|
||||
line,
|
||||
destination.path() + "/" + file
|
||||
destination.path() + "/" + file,
|
||||
overrideFiles
|
||||
);
|
||||
futures.push_back(future);
|
||||
if (future)
|
||||
futures.push_back(future);
|
||||
}
|
||||
isFinished = true;
|
||||
};
|
||||
@@ -195,6 +202,7 @@ std::vector<DownloadManager::FileFuture*> DownloadManager::downloadRequestFiles(
|
||||
FileFuture* f = downloadFile(
|
||||
fullRequest,
|
||||
requestFile,
|
||||
true,
|
||||
callback
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user