summaryrefslogtreecommitdiff
path: root/include/webassets.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2021-03-05 03:43:14 +0300
committerEd Tanous <ed@tanous.net>2021-03-15 19:51:27 +0300
commit153fdcfb61669959279e1e32bbdba1e9703c8936 (patch)
tree640dd1af3acc7ba15fd5311812d24d17660512b8 /include/webassets.hpp
parentb614e2bde68db6712228f8533f56f94e41fda624 (diff)
downloadbmcweb-153fdcfb61669959279e1e32bbdba1e9703c8936.tar.xz
Make missing static files directory non-fatal
Today, bmcweb requires the /usr/share/www directory to exist. In most cases where bmcweb was installed with make install, this is fine, but in development scenarios, we'd like to be able to boot. This commit moves what used to be a fatal error (the directory not existing) to a warning, to help with a common development issue I've seen before. Tested: Launched without a /usr/share/www directory present, and bmcweb launched successfully and did not throw an exception. Change-Id: I775fafd86a4e2eef0bf73836d31a78fb320b61c0 Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'include/webassets.hpp')
-rw-r--r--include/webassets.hpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/webassets.hpp b/include/webassets.hpp
index 3703c3064a..a4ec58b07d 100644
--- a/include/webassets.hpp
+++ b/include/webassets.hpp
@@ -52,7 +52,17 @@ inline void requestRoutes(App& app)
{".map", "application/json"}}};
std::filesystem::path rootpath{"/usr/share/www/"};
- std::filesystem::recursive_directory_iterator dirIter(rootpath);
+
+ std::error_code ec;
+
+ std::filesystem::recursive_directory_iterator dirIter(rootpath, ec);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Unable to find or open " << rootpath
+ << " static file hosting disabled";
+ return;
+ }
+
// In certain cases, we might have both a gzipped version of the file AND a
// non-gzipped version. To avoid duplicated routes, we need to make sure we
// get the gzipped version first. Because the gzipped path should be longer