1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
From 1b00440d0c8fabfa2e3eda984a21c0f004ca2150 Mon Sep 17 00:00:00 2001
From: Jennifer Lee <jennifer1.lee@intel.com>
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 <jennifer1.lee@intel.com>
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<int(std::string&)> 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<inotify_event*>(&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<Watch*>(userdata)->imageCallback(tarballPath);
--
2.17.1
|