Skip to content

Commit

Permalink
FS|Network: Remote feeds are expected to provide a list of packages
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 12, 2017
1 parent 68d590b commit c1972f6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doomsday/sdk/libcore/include/de/filesys/remote/link.h
Expand Up @@ -71,6 +71,12 @@ class DENG2_PUBLIC Link
*/
virtual PackagePaths locatePackages(StringList const &packageIds) const = 0;

/**
* Iterates the full list of all packages available in the repository. Note this
* may be large set of packages.
*/
virtual LoopResult forPackageIds(std::function<LoopResult (String const &packageId)> func) const = 0;

QueryId sendQuery(Query query);

virtual File *populateRemotePath(String const &packageId, RepositoryPath const &path) const;
Expand Down
2 changes: 2 additions & 0 deletions doomsday/sdk/libcore/include/de/filesys/remote/nativelink.h
Expand Up @@ -38,6 +38,8 @@ class DENG2_PUBLIC NativeLink : public Link

PackagePaths locatePackages(StringList const &packageIds) const override;

LoopResult forPackageIds(std::function<LoopResult (String const &packageId)> func) const override;

protected:
NativeLink(String const &address);

Expand Down
10 changes: 9 additions & 1 deletion doomsday/sdk/libcore/src/filesys/remote/link.cpp
Expand Up @@ -125,7 +125,15 @@ Link::Link(String const &address)
}

Link::~Link()
{}
{
d->cancelAllQueries();

// Normally, the local folder will be deleted when the link is disconnected.
if (auto *folder = FS::tryLocate<Folder>(d->localRootPath))
{
delete folder;
}
}

void Link::setLocalRoot(String const &rootPath)
{
Expand Down
12 changes: 12 additions & 0 deletions doomsday/sdk/libcore/src/filesys/remote/nativelink.cpp
Expand Up @@ -128,6 +128,18 @@ PackagePaths NativeLink::locatePackages(StringList const &packageIds) const
return remotePaths;
}

LoopResult filesys::NativeLink::forPackageIds(std::function<LoopResult (String const &)> func) const
{
return FS::locate<Folder>("/remote/server").forContents([&func] (String name, File &) -> LoopResult
{
if (auto result = func(name))
{
return result;
}
return LoopContinue;
});
}

void NativeLink::wasConnected()
{
d->socket << ByteRefArray("RemoteFeed", 10);
Expand Down

0 comments on commit c1972f6

Please sign in to comment.