Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
25aa17ad
Commit
25aa17ad
authored
Feb 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InotifyUpdate: move functions into the WatchDirectory class
parent
05ee057d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
+18
-13
InotifyUpdate.cxx
src/db/update/InotifyUpdate.cxx
+18
-13
No files found.
src/db/update/InotifyUpdate.cxx
View file @
25aa17ad
...
...
@@ -62,6 +62,12 @@ struct WatchDirectory {
WatchDirectory
(
const
WatchDirectory
&
)
=
delete
;
WatchDirectory
&
operator
=
(
const
WatchDirectory
&
)
=
delete
;
gcc_pure
unsigned
GetDepth
()
const
;
gcc_pure
AllocatedPath
GetUriFS
()
const
;
};
static
InotifySource
*
inotify_source
;
...
...
@@ -127,17 +133,17 @@ remove_watch_directory(WatchDirectory *directory)
});
}
static
AllocatedPath
watch_directory_get_uri_fs
(
const
WatchDirectory
*
directory
)
AllocatedPath
WatchDirectory
::
GetUriFS
()
const
{
if
(
directory
->
parent
==
nullptr
)
if
(
parent
==
nullptr
)
return
AllocatedPath
::
Null
();
const
auto
uri
=
watch_directory_get_uri_fs
(
directory
->
parent
);
const
auto
uri
=
parent
->
GetUriFS
(
);
if
(
uri
.
IsNull
())
return
directory
->
name
;
return
name
;
return
AllocatedPath
::
Build
(
uri
,
directory
->
name
);
return
AllocatedPath
::
Build
(
uri
,
name
);
}
/* we don't look at "." / ".." nor files with newlines in their name */
...
...
@@ -221,11 +227,10 @@ recursive_watch_subdirectories(WatchDirectory *directory,
}
gcc_pure
static
unsigned
watch_directory_depth
(
const
WatchDirectory
*
d
)
unsigned
WatchDirectory
::
GetDepth
()
const
{
assert
(
d
!=
nullptr
);
const
WatchDirectory
*
d
=
this
;
unsigned
depth
=
0
;
while
((
d
=
d
->
parent
)
!=
nullptr
)
++
depth
;
...
...
@@ -245,7 +250,7 @@ mpd_inotify_callback(int wd, unsigned mask,
if
(
directory
==
nullptr
)
return
;
const
auto
uri_fs
=
watch_directory_get_uri_fs
(
directory
);
const
auto
uri_fs
=
directory
->
GetUriFS
(
);
if
((
mask
&
(
IN_DELETE_SELF
|
IN_MOVE_SELF
))
!=
0
)
{
remove_watch_directory
(
directory
);
...
...
@@ -263,13 +268,13 @@ mpd_inotify_callback(int wd, unsigned mask,
:
AllocatedPath
::
Build
(
root
,
uri_fs
.
c_str
());
recursive_watch_subdirectories
(
directory
,
path_fs
,
watch_directory_depth
(
directory
));
directory
->
GetDepth
(
));
}
if
((
mask
&
(
IN_CLOSE_WRITE
|
IN_MOVE
|
IN_DELETE
))
!=
0
||
/* at the maximum depth, we watch out for newly created
directories */
(
watch_directory_depth
(
directory
)
==
inotify_max_depth
&&
(
directory
->
GetDepth
(
)
==
inotify_max_depth
&&
(
mask
&
(
IN_CREATE
|
IN_ISDIR
))
==
(
IN_CREATE
|
IN_ISDIR
)))
{
/* a file was changed, or a directory was
moved/deleted: queue a database update */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment