From 1b00440d0c8fabfa2e3eda984a21c0f004ca2150 Mon Sep 17 00:00:00 2001 From: Jennifer Lee Date: Fri, 26 Oct 2018 11:54:05 -0700 Subject: [PATCH 4/6] Changed the condition of software version service watching deamon Originally it watches only files that are "written" into /tmp/images directory. This change modified the condition to also watch files that are "moved" into this directory. Signed-off-by: Jennifer Lee Change-Id: I3e9cf1ffc3f5350d4649d32d3d3837991322a65b --- watch.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/watch.cpp b/watch.cpp index e46b8aa..eee1bc3 100644 --- a/watch.cpp +++ b/watch.cpp @@ -45,7 +45,7 @@ Watch::Watch(sd_event* loop, std::function imageCallback) : std::strerror(error)); } - wd = inotify_add_watch(fd, IMG_UPLOAD_DIR, IN_CLOSE_WRITE); + wd = inotify_add_watch(fd, IMG_UPLOAD_DIR, IN_CLOSE_WRITE | IN_MOVED_TO); if (-1 == wd) { auto error = errno; @@ -96,7 +96,8 @@ int Watch::callback(sd_event_source* s, int fd, uint32_t revents, while (offset < bytes) { auto event = reinterpret_cast(&buffer[offset]); - if ((event->mask & IN_CLOSE_WRITE) && !(event->mask & IN_ISDIR)) + if ((event->mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) && + !(event->mask & IN_ISDIR)) { auto tarballPath = std::string{IMG_UPLOAD_DIR} + '/' + event->name; auto rc = static_cast(userdata)->imageCallback(tarballPath); -- 2.17.1