Change inotify to look at IN_CLOSE_WRITE flag
The inotify is triggering before the image is done
downloading. This leads to a corrupted tar.
Look at the IN_CLOSE_WRITE flag instead.
Change-Id: Ib9d3f97ae3c48960a0bdf84250a66d1f8254a7f5
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/watch.cpp b/watch.cpp
index a520dd2..a690c57 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -29,7 +29,7 @@
"inotify_init1 failed, errno="s + std::strerror(error));
}
- wd = inotify_add_watch(fd, IMG_UPLOAD_DIR, IN_CREATE);
+ wd = inotify_add_watch(fd, IMG_UPLOAD_DIR, IN_CLOSE_WRITE);
if (-1 == wd)
{
auto error = errno;
@@ -84,7 +84,7 @@
while (offset < bytes)
{
auto event = reinterpret_cast<inotify_event*>(&buffer[offset]);
- if ((event->mask & IN_CREATE) && !(event->mask & IN_ISDIR))
+ if ((event->mask & IN_CLOSE_WRITE) && !(event->mask & IN_ISDIR))
{
// TODO: openbmc/openbmc#1352 - invoke method (which takes uploaded
// filepath) to construct software version d-bus objects.