aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-20 22:48:34 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-25 20:32:30 +0300
commit7407647bf6c73c1b128749ed788d53b5f174b4be (patch)
treec2ea4b5f745baa86b4ed414d21778f6ddfefa4c1 /mod
parent8c0326c9433d47dfbeab8d1514512de1160d5792 (diff)
Add support for submission simulating
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-submit.cxx20
-rw-r--r--mod/options.cli13
2 files changed, 19 insertions, 14 deletions
diff --git a/mod/mod-submit.cxx b/mod/mod-submit.cxx
index ff5fa9d..6dbb4ec 100644
--- a/mod/mod-submit.cxx
+++ b/mod/mod-submit.cxx
@@ -527,24 +527,20 @@ handle (request& rq, response& rs)
parser p (is, "handler");
manifest_name_value nv (p.next ());
- auto bad_name ([&p, &nv] (const string& d) {
- throw parsing (p.name (), nv.name_line, nv.name_column, d);});
-
auto bad_value ([&p, &nv] (const string& d) {
throw parsing (p.name (), nv.value_line, nv.value_column, d);});
+ if (nv.empty ())
+ bad_value ("empty manifest");
+
const string& n (nv.name);
const string& v (nv.value);
- // Make sure this is the start and we support the version.
+ // The format version pair is verified by the parser.
//
- if (!n.empty ())
- bad_name ("start of manifest expected");
-
- if (v != "1")
- bad_value ("unsupported format version");
+ assert (n.empty () && v == "1");
- // Cache start of manifest.
+ // Cache the format version pair.
//
rvs.push_back (move (nv));
@@ -656,7 +652,7 @@ handle (request& rq, response& rs)
return respond_error ();
}
- // Send email, if configured.
+ // Send email, if configured, and the submission is not simulated.
//
// Note that we don't consider the email sending failure to be a submission
// failure as the submission data is successfully persisted and the handler
@@ -666,7 +662,7 @@ handle (request& rq, response& rs)
// web server error log is monitored and the email sending failure will be
// noticed.
//
- if (options_->submit_email_specified ())
+ if (options_->submit_email_specified () && !params.simulate ())
try
{
// Redirect the diagnostics to the web server error log.
diff --git a/mod/options.cli b/mod/options.cli
index 62a339d..66f19b1 100644
--- a/mod/options.cli
+++ b/mod/options.cli
@@ -623,8 +623,8 @@ namespace brep
string result | rs = "*";
};
- // Parameters must either be all present (actual submission) or absent
- // (submission form request).
+ // Parameters, except simulate, must either be all present (actual
+ // submission) or absent (submission form request).
//
// Note also that besides these parameters there can be others. We don't
// recognize their semantics and just save them to the submission request
@@ -642,6 +642,15 @@ namespace brep
// Package archive file SHA256 checksum.
//
string sha256sum;
+
+ // Simulate submission. Tells the submission handler not to publish the
+ // package but to respond as if it does.
+ //
+ // Note that the package submission email (see submit-email
+ // configuration option for details) is not sent for the simulated
+ // submission.
+ //
+ bool simulate;
};
}
}