mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-05 23:48:44 +02:00
substantially rework file monitors
Remove all event merging and dispatch logic from GFileMonitor. The only implementation of GFileMonitor outside of glib is in gvfs and it already does these things properly. Get rid of GLocalDirectoryMonitor. We will use a single class, GLocalFileMonitor, for both directory and file monitoring. This will prevent every single backend from having to create two objects separately (eg: ginotifydirectorymonitor.c and ginotifyfilemonitor.c). Introduce GFileMonitorSource as a thread-safe cross-context dispatch mechanism. Put it in GLocalFileMonitor. All backends will be expected to dispatch via the source and not touch the GFileMonitor object at all from the worker thread. Remove all construct properties from GLocalFileMonitor and remove the "context" construct property from GFileMonitor. All backends must now get the information about what file to monitor from the ->start() call which is mandatory to implement. Remove the implementation of rate limiting in GFileMonitor and add an implementation in GLocalFileMonitor. gvfs never did anything with this anyway, but if it wanted to, it would have to implement it for itself. This was done in order to get the rate_limit field into the GFileMonitorSource so that it could be safely accessed from the worker thread. Expose g_local_file_is_remote() internally for NFS detection. With the "is_remote" functionality exposed, we can now move all functions for creating local file monitors to a proper location in glocalfilemonitor.c Port the inotify backend to adjust to the changes above. None of the other backends are ported yet. Those will come in future commits.
This commit is contained in:
@@ -56,7 +56,6 @@
|
||||
#include "glocalfileinputstream.h"
|
||||
#include "glocalfileoutputstream.h"
|
||||
#include "glocalfileiostream.h"
|
||||
#include "glocaldirectorymonitor.h"
|
||||
#include "glocalfilemonitor.h"
|
||||
#include "gmountprivate.h"
|
||||
#include "gunixmounts.h"
|
||||
@@ -2451,8 +2450,8 @@ g_local_file_move (GFile *source,
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
static gboolean
|
||||
is_remote (const gchar *filename)
|
||||
gboolean
|
||||
g_local_file_is_remote (const gchar *filename)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2508,8 +2507,8 @@ is_remote_fs (const gchar *filename)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_remote (const gchar *filename)
|
||||
gboolean
|
||||
g_local_file_is_remote (const gchar *filename)
|
||||
{
|
||||
static gboolean remote_home;
|
||||
static gsize initialized;
|
||||
@@ -2536,8 +2535,9 @@ g_local_file_monitor_dir (GFile *file,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GLocalFile* local_file = G_LOCAL_FILE(file);
|
||||
return _g_local_directory_monitor_new (local_file->filename, flags, NULL, is_remote (local_file->filename), TRUE, error);
|
||||
GLocalFile *local_file = G_LOCAL_FILE (file);
|
||||
|
||||
return g_local_file_monitor_new_for_path (local_file->filename, TRUE, flags, error);
|
||||
}
|
||||
|
||||
static GFileMonitor*
|
||||
@@ -2546,31 +2546,11 @@ g_local_file_monitor_file (GFile *file,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GLocalFile* local_file = G_LOCAL_FILE(file);
|
||||
return _g_local_file_monitor_new (local_file->filename, flags, NULL, is_remote (local_file->filename), TRUE, error);
|
||||
}
|
||||
GLocalFile *local_file = G_LOCAL_FILE (file);
|
||||
|
||||
GLocalDirectoryMonitor *
|
||||
g_local_directory_monitor_new_in_worker (const char *pathname,
|
||||
GFileMonitorFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
return (gpointer) _g_local_directory_monitor_new (pathname, flags,
|
||||
GLIB_PRIVATE_CALL (g_get_worker_context) (),
|
||||
is_remote (pathname), FALSE, error);
|
||||
return g_local_file_monitor_new_for_path (local_file->filename, FALSE, flags, error);
|
||||
}
|
||||
|
||||
GLocalFileMonitor *
|
||||
g_local_file_monitor_new_in_worker (const char *pathname,
|
||||
GFileMonitorFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
return (gpointer) _g_local_file_monitor_new (pathname, flags,
|
||||
GLIB_PRIVATE_CALL (g_get_worker_context) (),
|
||||
is_remote (pathname), FALSE, error);
|
||||
}
|
||||
|
||||
|
||||
/* Here is the GLocalFile implementation of g_file_measure_disk_usage().
|
||||
*
|
||||
* If available, we use fopenat() in preference to filenames for
|
||||
|
Reference in New Issue
Block a user