fs: Enhanced ignore list to do glob match. (#1910)

Fixes #1902
This commit is contained in:
Harshavardhana
2016-12-05 14:07:18 -08:00
committed by GitHub
parent 1e48d10617
commit f0d926ebba
2 changed files with 19 additions and 5 deletions
+15 -4
View File
@@ -45,8 +45,8 @@ const (
var ( // GOOS specific ignore list.
ignoreFiles = map[string][]string{
"darwin": {".DS_Store"},
// "default": []string{""},
"darwin": {"*.DS_Store"},
"default": {"*.part.minio"},
}
)
@@ -66,14 +66,22 @@ func isIgnoredFile(filename string) bool {
// OS specific ignore list.
for _, ignoredFile := range ignoreFiles[runtime.GOOS] {
if ignoredFile == matchFile {
matched, err := filepath.Match(ignoredFile, matchFile)
if err != nil {
panic(err)
}
if matched {
return true
}
}
// Default ignore list for all OSes.
for _, ignoredFile := range ignoreFiles["default"] {
if ignoredFile == matchFile {
matched, err := filepath.Match(ignoredFile, matchFile)
if err != nil {
panic(err)
}
if matched {
return true
}
}
@@ -137,6 +145,9 @@ func (f *fsClient) Watch(params watchParams) (*watchObject, *probe.Error) {
if !ok {
return
}
if isIgnoredFile(event.Path()) {
continue
}
var i os.FileInfo
if IsPutEvent(event.Event()) {
// Look for any writes, send a response to indicate a full copy.
+4 -1
View File
@@ -168,6 +168,9 @@ func mainWatch(ctx *cli.Context) error {
for {
select {
case <-trapCh:
// Signal received we are done.
close(wo.done)
return
case event, ok := <-wo.Events():
if !ok {
return
@@ -178,7 +181,7 @@ func mainWatch(ctx *cli.Context) error {
if !ok {
return
}
fatalIf(err, "Cannot watch on events.")
errorIf(err, "Cannot watch on events.")
return
}
}