summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-11-09 15:43:50 -0600
committerGunnar Mills <gmills@us.ibm.com>2017-11-13 15:35:57 -0600
commit7e1abfcab8ab4b918a0725a0d91b998dff116eec (patch)
tree2c5d5fb92f12579d66635aa7caad95419b33126d
parent7a248bc7c30ed1fdb7d6b4255eea2430852333d1 (diff)
downloadphosphor-bmc-code-mgmt-7e1abfcab8ab4b918a0725a0d91b998dff116eec.tar.gz
phosphor-bmc-code-mgmt-7e1abfcab8ab4b918a0725a0d91b998dff116eec.zip
Create Image Dir if not present
Instead of throwing an error, create the image directory, if not present. The inotify code should create the image directory if not present, not the upload or TFTP code. Removed creating the image directory from the TFTP here and removed from the upload in another commit. Change-Id: I8c142283cfd5a3c87bdf2291d2e79729ec9ac319 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r--download_manager.cpp6
-rw-r--r--watch.cpp5
2 files changed, 5 insertions, 6 deletions
diff --git a/download_manager.cpp b/download_manager.cpp
index 35c8109..b89ac22 100644
--- a/download_manager.cpp
+++ b/download_manager.cpp
@@ -55,11 +55,13 @@ void Download::downloadViaTFTP(std::string fileName,
entry("FILENAME=%s", fileName),
entry("SERVERADDRESS=%s", serverAddress));
- // Check if IMAGE DIR exists and create if necessary.
+ // Check if IMAGE DIR exists
fs::path imgDirPath(IMG_UPLOAD_DIR);
if (!fs::is_directory(imgDirPath))
{
- fs::create_directory(imgDirPath);
+ log<level::ERR>("Error Image Dir does not exist");
+ elog<InternalFailure>();
+ return;
}
pid_t pid = fork();
diff --git a/watch.cpp b/watch.cpp
index 9921bbd..c3aa7e9 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -29,10 +29,7 @@ Watch::Watch(sd_event* loop,
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});
+ fs::create_directories(imgDirPath);
}
fd = inotify_init1(IN_NONBLOCK);
OpenPOWER on IntegriCloud