Skip to content

Commit

Permalink
FS|libcore: No errors about empty container packages without metadata
Browse files Browse the repository at this point in the history
An empty .pack folder is allowed if it is used for nesting.
  • Loading branch information
skyjake committed Jun 26, 2016
1 parent 794555d commit 2fe7f26
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
4 changes: 4 additions & 0 deletions doomsday/sdk/libcore/include/de/filesys/package.h
Expand Up @@ -53,6 +53,9 @@ class DENG2_PUBLIC Package : public IObject
/// Package fails validation. @ingroup errors
DENG2_ERROR(ValidationError);

/// Checked metadata does not describe a package. @ingroup errors
DENG2_SUB_ERROR(ValidationError, NotPackageError);

/// Package is missing some required metadata. @ingroup errors
DENG2_SUB_ERROR(ValidationError, IncompleteMetadataError);

Expand Down Expand Up @@ -212,6 +215,7 @@ class DENG2_PUBLIC Package : public IObject

static String const VAR_PACKAGE;
static String const VAR_PACKAGE_ID;
static String const VAR_PACKAGE_ALIAS;
static String const VAR_TITLE;

private:
Expand Down
19 changes: 12 additions & 7 deletions doomsday/sdk/libcore/src/filesys/package.cpp
Expand Up @@ -19,6 +19,7 @@
#include "de/Package"
#include "de/App"
#include "de/DotPath"
#include "de/LogBuffer"
#include "de/PackageLoader"
#include "de/Process"
#include "de/Script"
Expand All @@ -28,9 +29,10 @@

namespace de {

String const Package::VAR_PACKAGE ("package");
String const Package::VAR_PACKAGE_ID("package.ID");
String const Package::VAR_TITLE ("title");
String const Package::VAR_PACKAGE ("package");
String const Package::VAR_PACKAGE_ID ("package.ID");
String const Package::VAR_PACKAGE_ALIAS("package.alias");
String const Package::VAR_TITLE ("title");

static String const PACKAGE_ORDER ("package.__order__");
static String const PACKAGE_IMPORT_PATH("package.importPath");
Expand Down Expand Up @@ -266,17 +268,20 @@ void Package::parseMetadata(File &packageFile) // static

metadata.addTime(TIMESTAMP, parsedAt);

LOGDEV_RES_MSG("Parsed metadata of '%s':\n" _E(m))
<< identifierForFile(packageFile)
<< packageFile.objectNamespace().asText();
if (LogBuffer::get().isEnabled(LogEntry::Dev | LogEntry::XVerbose | LogEntry::Resource))
{
LOGDEV_RES_XVERBOSE("Parsed metadata of '%s':\n" _E(m))
<< identifierForFile(packageFile)
<< packageFile.objectNamespace().asText();
}
}
}

void Package::validateMetadata(Record const &packageInfo)
{
if (!packageInfo.has(VAR_ID))
{
throw ValidationError("Package::validateMetadata", "Not a package");
throw NotPackageError("Package::validateMetadata", "Not a package");
}

// A domain is required in all package identifiers.
Expand Down
13 changes: 9 additions & 4 deletions doomsday/sdk/libcore/src/filesys/packageloader.cpp
Expand Up @@ -120,7 +120,7 @@ DENG2_PIMPL(PackageLoader)

if (!packFile.objectNamespace().has(Package::VAR_PACKAGE))
{
throw Package::ValidationError("PackageLoader::checkPackage",
throw Package::NotPackageError("PackageLoader::checkPackage",
packFile.description() + " is not a package");
}

Expand Down Expand Up @@ -249,20 +249,25 @@ DENG2_PIMPL(PackageLoader)

list.append(path);
}
catch (Package::NotPackageError const &er)
{
// This is usually a .pack folder used only for nesting.
LOG_RES_XVERBOSE("\"%s\": %s") << i->first << er.asText();
}
catch (Package::ValidationError const &er)
{
// Not a loadable package.
qDebug() << i->first << ": Package is invalid:" << er.asText();
LOG_RES_MSG("\"%s\": Package is invalid: %s") << i->first << er.asText();
}
catch (Parser::SyntaxError const &er)
{
LOG_RES_NOTE("\"%s\": Package has a Doomsday Script syntax error: %s")
LOG_RES_WARNING("\"%s\": Package has a Doomsday Script syntax error: %s")
<< i->first << er.asText();
}
catch (Info::SyntaxError const &er)
{
// Not a loadable package.
LOG_RES_NOTE("\"%s\": Package has a syntax error: %s")
LOG_RES_WARNING("\"%s\": Package has a syntax error: %s")
<< i->first << er.asText();
}

Expand Down

0 comments on commit 2fe7f26

Please sign in to comment.