Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Configuration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Application
Configuration
Commits
896b5d75
Verified
Commit
896b5d75
authored
2 years ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix monitor directories not files
parent
1481483d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
import.go
+3
-3
3 additions, 3 deletions
import.go
settings.go
+1
-1
1 addition, 1 deletion
settings.go
watch.go
+20
-1
20 additions, 1 deletion
watch.go
with
24 additions
and
5 deletions
import.go
+
3
−
3
View file @
896b5d75
...
...
@@ -95,7 +95,7 @@ func (s *Settings[C]) importFiles() {
s
.
fileWatch
.
Lock
()
// new files may have been added
tmpWatchList
:=
make
(
map
[
string
]
string
)
tmpWatchList
:=
make
(
map
[
string
]
bool
)
defer
func
()
{
s
.
fileWatch
.
watchList
=
tmpWatchList
...
...
@@ -123,7 +123,7 @@ func (s *Settings[C]) importFiles() {
s
.
importStream
(
reader
{
s
.
files
.
format
,
r
})
f
.
Close
()
tmpWatchList
[
fn
]
=
fn
tmpWatchList
[
fn
]
=
true
}
...
...
@@ -138,7 +138,7 @@ func (s *Settings[C]) importFiles() {
s
.
importStream
(
reader
{
f
.
format
,
r
})
r
.
Close
()
tmpWatchList
[
f
.
path
]
=
f
.
path
tmpWatchList
[
f
.
path
]
=
true
}
}
...
...
This diff is collapsed.
Click to expand it.
settings.go
+
1
−
1
View file @
896b5d75
...
...
@@ -13,7 +13,7 @@ import (
type
fileWatch
struct
{
sync
.
Mutex
watcher
*
fsnotify
.
Watcher
watchList
map
[
string
]
string
watchList
map
[
string
]
bool
cancelWatch
chan
bool
onWatch
bool
}
...
...
This diff is collapsed.
Click to expand it.
watch.go
+
20
−
1
View file @
896b5d75
...
...
@@ -5,6 +5,8 @@ package configuration
import
(
"github.com/fsnotify/fsnotify"
"os"
"path"
)
func
(
s
*
Settings
[
C
])
initWatch
()
*
Settings
[
C
]
{
...
...
@@ -97,7 +99,19 @@ func (s *Settings[C]) Watch() *Settings[C] {
// add all files to the watch list
for
file
:=
range
s
.
fileWatch
.
watchList
{
err
:=
s
.
fileWatch
.
watcher
.
Add
(
file
)
fileInfo
,
err
:=
os
.
Stat
(
file
)
if
err
!=
nil
{
s
.
errors
=
append
(
s
.
errors
,
err
)
continue
}
if
fileInfo
.
IsDir
()
{
err
=
s
.
fileWatch
.
watcher
.
Add
(
file
)
}
else
{
err
=
s
.
fileWatch
.
watcher
.
Add
(
path
.
Dir
(
file
))
}
if
err
!=
nil
{
s
.
errors
=
append
(
s
.
errors
,
err
)
}
...
...
@@ -119,6 +133,11 @@ func (s *Settings[C]) Watch() *Settings[C] {
return
}
_
,
exist
:=
s
.
fileWatch
.
watchList
[
event
.
Name
]
if
!
exist
{
continue
}
if
event
.
Op
&
fsnotify
.
Write
==
fsnotify
.
Write
{
s
.
Import
()
}
else
if
event
.
Op
&
fsnotify
.
Remove
==
fsnotify
.
Remove
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment