Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/efsw/efsw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ class FileWatchListener {
virtual void handleFileAction( WatchID watchid, const std::string& dir,
const std::string& filename, Action action,
std::string oldFilename = "" ) = 0;

/// Handles that have missed file actions
/// @param watchid The watch id for the directory
/// @param dir The directory
virtual void handleMissedFileActions( WatchID /*watchid*/,
const std::string& /*dir*/ ) {};
};

/// Optional, typically platform specific parameter for customization of a watcher.
Expand Down
4 changes: 3 additions & 1 deletion src/efsw/FileWatcherInotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@ void FileWatcherInotify::handleAction( Watcher* watch, const std::string& filena

std::string fpath( watch->Directory + filename );

if ( ( IN_CLOSE_WRITE & action ) || ( IN_MODIFY & action ) ) {
if ( IN_Q_OVERFLOW & action ) {
watch->Listener->handleMissedFileActions( watch->ID, watch->Directory );
} else if ( ( IN_CLOSE_WRITE & action ) || ( IN_MODIFY & action ) ) {
watch->Listener->handleFileAction( watch->ID, watch->Directory, filename,
Actions::Modified );
} else if ( IN_MOVED_TO & action ) {
Expand Down
17 changes: 16 additions & 1 deletion src/efsw/WatcherFSEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ void WatcherFSEvents::sendFileAction( WatchID watchid, const std::string& dir,
FileSystem::precomposeFileName( oldFilename ) );
}

void WatcherFSEvents::sendMissedFileActions( WatchID watchid,
const std::string& dir) {
Listener->handleMissedFileActions( watchid,
FileSystem::precomposeFileName( dir ) );
}

void WatcherFSEvents::handleAddModDel( const Uint32& flags, const std::string& path,
std::string& dirPath, std::string& filePath, Uint64 inode ) {
if ( ( flags & efswFSEventStreamEventFlagItemCreated ) && FileInfo::exists( path ) &&
Expand Down Expand Up @@ -97,7 +103,16 @@ void WatcherFSEvents::handleActions( std::vector<FSEvent>& events ) {

if ( event.Flags &
( kFSEventStreamEventFlagUserDropped | kFSEventStreamEventFlagKernelDropped |
kFSEventStreamEventFlagEventIdsWrapped | kFSEventStreamEventFlagHistoryDone |
kFSEventStreamEventFlagMustScanSubDirs) ) {
efDEBUG( "Rescan/Drop event for watch: %s - flags: 0x%x\n", Directory.c_str(), event.Flags );
std::string dirPath = Directory;
FileSystem::dirRemoveSlashAtEnd( dirPath );
sendMissedFileActions(ID, dirPath );
continue;
}

if ( event.Flags &
( kFSEventStreamEventFlagEventIdsWrapped | kFSEventStreamEventFlagHistoryDone |
kFSEventStreamEventFlagMount | kFSEventStreamEventFlagUnmount |
kFSEventStreamEventFlagRootChanged ) ) {
continue;
Expand Down
2 changes: 2 additions & 0 deletions src/efsw/WatcherFSEvents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class WatcherFSEvents : public Watcher {

void sendFileAction( WatchID watchid, const std::string& dir, const std::string& filename,
Action action, std::string oldFilename = "" );

void sendMissedFileActions( WatchID watchid, const std::string& dir);
};

} // namespace efsw
Expand Down
5 changes: 5 additions & 0 deletions src/efsw/WatcherWin32.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <efsw/Debug.hpp>
#include <efsw/FileSystem.hpp>
#include <efsw/String.hpp>
#include <efsw/WatcherWin32.hpp>

Expand Down Expand Up @@ -162,6 +163,10 @@ void CALLBACK WatchCallback( DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOve

if ( dwNumberOfBytesTransfered == 0 ) {
if ( nullptr != pWatch && !pWatch->StopNow ) {
/// Missed file actions due to buffer overflowed
std::string dir = pWatch->DirName;
FileSystem::dirRemoveSlashAtEnd( dir );
pWatch->Listener->handleMissedFileActions( pWatch->ID, dir );
RefreshWatch( tWatch );
} else {
return;
Expand Down
Loading