Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fetch files list issue on windows #754

Closed
wants to merge 1 commit into from

Conversation

masato25
Copy link

Fix fetch files list issue on Windows.

sorry for the wrong pull request many times. :(

@@ -120,6 +120,12 @@ def expand_paths
@paths.each { |path|
path = date.strftime(path)
if path.include?('*')

#fix fetch files list issue on windows
if(path =~ /^\s*[C-Z]:\\/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove () like above if condition?

@repeatedly
Copy link
Member

@nurse Could you check this approach? Is this good or does Ruby have proper way?

@nurse
Copy link
Contributor

nurse commented Dec 20, 2015

@masato25 What issue do you want to solve? Could you show an example case?

@masato25
Copy link
Author

HI @nurse , nice to talk with you.
I had tried the tail plugin to watch bunch of files in a folder on Windows OS.
ex. C:\test*.csv
But it's seems doesn't works. so I look into the source code of tail plugin.

         paths += Dir.glob(path).select { |p|
            if File.readable?(p)
              true
            else
              log.warn "#{p} unreadable. It is excluded and would be examined next time."
              false
            end
          }

and I checked Ruby Doc, the document mention

\
Escapes the next metacharacter.

Note that this means you cannot use backslash on windows as part of a glob, i.e. Dir["c:\foo*"] will not work, use Dir["c:/foo*"] instead.

I followed the doc's solutions to change "c:\test*.csv" into "c:/test/*.csv" and that is works.

I just think If fluentd can native support for automatic fixed this kind of problem will be more friendly for Winodws users, so I did this pull request.

Thanks
Masato

@nurse
Copy link
Contributor

nurse commented Dec 21, 2015

It sounds reasonable.
You can use Fluent.windows? instead of (path =~ /^\s*[C-Z]:\\/) as the begining of the file, and tr!('', '/') instead of gsub. The code should be in def configure.

@nurse
Copy link
Contributor

nurse commented Apr 26, 2016

As wrote in #919 (comment), it breaks if there's a file which has glob meta character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants