IDEA-109028 (fsnotifier to not panic on incorrect paths)

This commit is contained in:
Roman Shevchenko
2013-06-17 20:01:06 +04:00
parent ab007f2b9a
commit 5358d44522
5 changed files with 30 additions and 7 deletions
Binary file not shown.
Binary file not shown.
+9 -6
View File
@@ -305,14 +305,17 @@ int watch(const char* root, array* mounts) {
struct stat st;
if (stat(root, &st) != 0) {
if (errno == EACCES) {
return ERR_IGNORE;
}
else if (errno == ENOENT) {
if (errno == ENOENT) {
return ERR_MISSING;
}
userlog(LOG_ERR, "stat(%s): %s", root, strerror(errno));
return ERR_ABORT;
else if (errno == EACCES || errno == ELOOP || errno == ENAMETOOLONG || errno == ENOTDIR) {
userlog(LOG_INFO, "stat(%s): %s", root, strerror(errno));
return ERR_CONTINUE;
}
else {
userlog(LOG_ERR, "stat(%s): %s", root, strerror(errno));
return ERR_ABORT;
}
}
if (S_ISREG(st.st_mode)) {
+1 -1
View File
@@ -36,7 +36,7 @@
#define LOG_ENV_ERROR "error"
#define LOG_ENV_OFF "off"
#define VERSION "20130415.2136"
#define VERSION "20130617.1827"
#define VERSION_MSG "fsnotifier " VERSION "\n"
#define USAGE_MSG \
@@ -292,6 +292,26 @@ public class FileWatcherTest extends PlatformLangTestCase {
}
}
public void testIncorrectPath() throws Exception {
File topDir = createTestDir("top");
File file = createTestFile(topDir, "file.zip");
File subDir = new File(file, "sub/zip");
refresh(topDir);
LocalFileSystem.WatchRequest request = watch(subDir, false);
try {
myTimeout = 10 * INTER_RESPONSE_DELAY;
myAccept = true;
FileUtil.writeToFile(file, "new content");
assertEvent(VFileEvent.class);
myTimeout = NATIVE_PROCESS_DELAY;
}
finally {
unwatch(request);
delete(topDir);
}
}
public void testDirectoryOverlapping() throws Exception {
File topDir = createTestDir("top");
File fileInTopDir = createTestFile(topDir, "file1.txt");