Golint fixes
I used: `golint | grep -v comment | grep -v stringer` to avoid crap.
This commit is contained in:
@@ -43,7 +43,7 @@ func ConfigWatch(file string) chan bool {
|
||||
patharray := PathSplit(safename) // tokenize the path
|
||||
var index = len(patharray) // starting index
|
||||
var current string // current "watcher" location
|
||||
var delta_depth int // depth delta between watcher and event
|
||||
var deltaDepth int // depth delta between watcher and event
|
||||
var send = false // send event?
|
||||
|
||||
for {
|
||||
@@ -73,17 +73,17 @@ func ConfigWatch(file string) chan bool {
|
||||
|
||||
select {
|
||||
case event := <-watcher.Events:
|
||||
// the deeper you go, the bigger the delta_depth is...
|
||||
// the deeper you go, the bigger the deltaDepth is...
|
||||
// this is the difference between what we're watching,
|
||||
// and the event... doesn't mean we can't watch deeper
|
||||
if current == event.Name {
|
||||
delta_depth = 0 // i was watching what i was looking for
|
||||
deltaDepth = 0 // i was watching what i was looking for
|
||||
|
||||
} else if HasPathPrefix(event.Name, current) {
|
||||
delta_depth = len(PathSplit(current)) - len(PathSplit(event.Name)) // -1 or less
|
||||
deltaDepth = len(PathSplit(current)) - len(PathSplit(event.Name)) // -1 or less
|
||||
|
||||
} else if HasPathPrefix(current, event.Name) {
|
||||
delta_depth = len(PathSplit(event.Name)) - len(PathSplit(current)) // +1 or more
|
||||
deltaDepth = len(PathSplit(event.Name)) - len(PathSplit(current)) // +1 or more
|
||||
|
||||
} else {
|
||||
// TODO different watchers get each others events!
|
||||
@@ -92,7 +92,7 @@ func ConfigWatch(file string) chan bool {
|
||||
// event.Name: /tmp/mgmt/f3 and current: /tmp/mgmt/f2
|
||||
continue
|
||||
}
|
||||
//log.Printf("The delta depth is: %v", delta_depth)
|
||||
//log.Printf("The delta depth is: %v", deltaDepth)
|
||||
|
||||
// if we have what we wanted, awesome, send an event...
|
||||
if event.Name == safename {
|
||||
@@ -100,14 +100,14 @@ func ConfigWatch(file string) chan bool {
|
||||
send = true
|
||||
|
||||
// file removed, move the watch upwards
|
||||
if delta_depth >= 0 && (event.Op&fsnotify.Remove == fsnotify.Remove) {
|
||||
if deltaDepth >= 0 && (event.Op&fsnotify.Remove == fsnotify.Remove) {
|
||||
//log.Println("Removal!")
|
||||
watcher.Remove(current)
|
||||
index--
|
||||
}
|
||||
|
||||
// we must be a parent watcher, so descend in
|
||||
if delta_depth < 0 {
|
||||
if deltaDepth < 0 {
|
||||
watcher.Remove(current)
|
||||
index++
|
||||
}
|
||||
@@ -116,13 +116,13 @@ func ConfigWatch(file string) chan bool {
|
||||
} else if HasPathPrefix(safename, event.Name) {
|
||||
//log.Println("Above!")
|
||||
|
||||
if delta_depth >= 0 && (event.Op&fsnotify.Remove == fsnotify.Remove) {
|
||||
if deltaDepth >= 0 && (event.Op&fsnotify.Remove == fsnotify.Remove) {
|
||||
log.Println("Removal!")
|
||||
watcher.Remove(current)
|
||||
index--
|
||||
}
|
||||
|
||||
if delta_depth < 0 {
|
||||
if deltaDepth < 0 {
|
||||
log.Println("Parent!")
|
||||
if PathPrefixDelta(safename, event.Name) == 1 { // we're the parent dir
|
||||
//send = true
|
||||
|
||||
Reference in New Issue
Block a user