Skip to content

Commit

Permalink
FS|libcore: Package version may be checked from the file metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 4, 2017
1 parent 6aba621 commit bdd3ae2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Expand Up @@ -61,6 +61,8 @@ class DENG2_PUBLIC RemoteFeedRelay

void removeRepository(String const &address);

Link *repository(String const &address) const;

StringList repositories() const;

bool isConnected(String const &address) const;
Expand Down
6 changes: 6 additions & 0 deletions doomsday/sdk/libcore/src/filesys/package.cpp
Expand Up @@ -40,6 +40,7 @@ String const Package::VAR_ID ("ID");
String const Package::VAR_TITLE ("title");
String const Package::VAR_VERSION ("version");

static String const PACKAGE_VERSION ("package.version");
static String const PACKAGE_ORDER ("package.__order__");
static String const PACKAGE_IMPORT_PATH("package.importPath");
static String const PACKAGE_REQUIRES ("package.requires");
Expand Down Expand Up @@ -482,6 +483,11 @@ String Package::versionedIdentifierForFile(File const &file)
{
return String("%1_%2").arg(id).arg(id_ver.second.fullNumber());
}
// The version may be specified in metadata.
if (auto const *pkgVer = file.objectNamespace().tryFind(PACKAGE_VERSION))
{
return String("%1_%2").arg(id).arg(Version(pkgVer->value().asText()).fullNumber());
}
return id;
}

Expand Down
15 changes: 12 additions & 3 deletions doomsday/sdk/libcore/src/filesys/remote/remotefeedrelay.cpp
Expand Up @@ -107,6 +107,16 @@ void RemoteFeedRelay::removeRepository(String const &address)
}
}

Link *RemoteFeedRelay::repository(String const &address) const
{
auto found = d->repositories.constFind(address);
if (found != d->repositories.constEnd())
{
return found.value();
}
return nullptr;
}

StringList RemoteFeedRelay::repositories() const
{
StringList repos;
Expand All @@ -119,10 +129,9 @@ StringList RemoteFeedRelay::repositories() const

bool RemoteFeedRelay::isConnected(String const &address) const
{
auto found = d->repositories.constFind(address);
if (found != d->repositories.constEnd())
if (auto *repo = repository(address))
{
return found.value()->state() == Link::Ready;
return repo->state() == Link::Ready;
}
return false;
}
Expand Down

0 comments on commit bdd3ae2

Please sign in to comment.