Skip to content

Commit

Permalink
fix: Implement file monitoring based on different watchtypes
Browse files Browse the repository at this point in the history
Implement file monitoring based on different watchtypes

Log: Implement file monitoring based on different watchtypes
  • Loading branch information
liyigang1 authored and Johnson-zs committed Aug 19, 2024
1 parent 7470fa5 commit 9f0e5a5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dfm-io/dfm-io/dwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ DWatcherPrivate::~DWatcherPrivate()

GFileMonitor *DWatcherPrivate::createMonitor(GFile *gfile, DWatcher::WatchType type)
{
Q_UNUSED(type)

if (!gfile) {
error.setCode(DFMIOErrorCode(DFM_IO_ERROR_NOT_FOUND));
return nullptr;
Expand All @@ -36,7 +34,14 @@ GFileMonitor *DWatcherPrivate::createMonitor(GFile *gfile, DWatcher::WatchType t
g_autoptr(GCancellable) cancel = g_cancellable_new();

GFileMonitorFlags flags = GFileMonitorFlags(G_FILE_MONITOR_WATCH_MOUNTS | G_FILE_MONITOR_WATCH_MOVES);
gmonitor = g_file_monitor(gfile, flags, cancel, &gerror);
if (type == DWatcher::WatchType::kAuto) {
gmonitor = g_file_monitor(gfile, flags, cancel, &gerror);
} else if (type == DWatcher::WatchType::kDir) {
gmonitor = g_file_monitor_directory(gfile, flags, cancel, &gerror);
} else {
gmonitor = g_file_monitor_file(gfile, flags, cancel, &gerror);
}


if (!gmonitor) {
setErrorFromGError(gerror);
Expand Down

0 comments on commit 9f0e5a5

Please sign in to comment.