mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-07 04:49:00 -06:00
Decentralize resource synchronization. Remove notion of SynchronizationJob.
This commit is contained in:
@@ -106,12 +106,13 @@ std::string HttpSynchronization::directory() {
|
||||
return FileSys.absPath(d);
|
||||
}
|
||||
|
||||
void HttpSynchronization::synchronize() {
|
||||
void HttpSynchronization::start() {
|
||||
if (hasSyncFile()) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Do this in a new thread!
|
||||
std::vector<std::string> listUrls = fileListUrls();
|
||||
for (const auto& url : listUrls) {
|
||||
if (trySyncFromUrl(url)) {
|
||||
@@ -120,7 +121,13 @@ void HttpSynchronization::synchronize() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpSynchronization::cancel() {
|
||||
}
|
||||
|
||||
void HttpSynchronization::clear() {
|
||||
}
|
||||
|
||||
std::vector<std::string> HttpSynchronization::fileListUrls() {
|
||||
std::string query = std::string("?") + QueryKeyIdentifier + "=" + _identifier +
|
||||
"&" + QueryKeyFileVersion + "=" + std::to_string(_version) +
|
||||
|
||||
@@ -42,7 +42,10 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
std::string directory() override;
|
||||
void synchronize() override;
|
||||
void start() override;
|
||||
void cancel() override;
|
||||
void clear() override;
|
||||
|
||||
float nSynchronizedBytes() override;
|
||||
float nTotalBytes() override;
|
||||
bool nTotalBytesIsKnown() override;
|
||||
|
||||
@@ -110,16 +110,19 @@ std::string TorrentSynchronization::directory() {
|
||||
return FileSys.absPath(d);
|
||||
}
|
||||
|
||||
void TorrentSynchronization::synchronize() {
|
||||
_torrentClient->addMagnetLink(_magnetLink, directory());
|
||||
|
||||
bool hasSyncFile();
|
||||
void createSyncFile();
|
||||
|
||||
void TorrentSynchronization::start() {
|
||||
size_t torrentId = _torrentClient->addMagnetLink(_magnetLink, directory());
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
void TorrentSynchronization::cancel() {
|
||||
}
|
||||
|
||||
void TorrentSynchronization::clear() {
|
||||
}
|
||||
|
||||
|
||||
float TorrentSynchronization::nSynchronizedBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,9 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
std::string directory() override;
|
||||
void synchronize() override;
|
||||
void start() override;
|
||||
void cancel() override;
|
||||
void clear() override;
|
||||
|
||||
float nSynchronizedBytes() override;
|
||||
float nTotalBytes() override;
|
||||
|
||||
Reference in New Issue
Block a user