diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2017-04-28 09:53:02 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-05-24 05:00:16 +0000 |
commit | 4e48fd582e86bd8246a5602dde4b5f644ae03d11 (patch) | |
tree | de8e88316377a42a74c12b850d71cf31086a5217 /watch.cpp | |
parent | 9b7c0b6da3e764cf51baf6b87ab4297a39ab782f (diff) | |
download | phosphor-bmc-code-mgmt-4e48fd582e86bd8246a5602dde4b5f644ae03d11.tar.gz phosphor-bmc-code-mgmt-4e48fd582e86bd8246a5602dde4b5f644ae03d11.zip |
Check if image upload dir exists
The inotify doesn't work if the image upload
dir doesn't exist. If the image dir doesn't exist log an error.
Change-Id: I2b8c49182f2f19b8343587f4723575b6f6fc8781
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'watch.cpp')
-rw-r--r-- | watch.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -4,6 +4,7 @@ #include <string> #include <sys/inotify.h> #include <unistd.h> +#include <experimental/filesystem> #include <phosphor-logging/log.hpp> #include "config.h" #include "watch.hpp" @@ -18,9 +19,20 @@ namespace manager using namespace phosphor::logging; using namespace std::string_literals; +namespace fs = std::experimental::filesystem; Watch::Watch(sd_event* loop) { + // Check if IMAGE DIR exists. + fs::path imgDirPath(IMG_UPLOAD_DIR); + if (!fs::is_directory(imgDirPath)) + { + log<level::ERR>("ERROR No Image Dir", + entry("IMAGEDIR=%s", IMG_UPLOAD_DIR)); + throw std::runtime_error( + "No Image Dir, IMAGEDIR=" + std::string{IMG_UPLOAD_DIR}); + } + fd = inotify_init1(IN_NONBLOCK); if (-1 == fd) { |