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

FileList is not unique #225

Closed
BertramScharpf opened this issue Sep 22, 2017 · 4 comments
Closed

FileList is not unique #225

BertramScharpf opened this issue Sep 22, 2017 · 4 comments

Comments

@BertramScharpf
Copy link

Rakefile:

task :list do
  FileList[ "texput.*", "*.log"].each { |f| puts "==== #{f}" }
end
task :clean do
  FileList[ "texput.*", "*.log"].each { |f| rm f }
end

ls output:

Rakefile
dummy.log
texput.log
texput.tex

Rake commands:

$ rake list
==== texput.log
==== texput.texrm texput.log
==== dummy.log
==== texput.log
$ rake clean
rm texput.tex
rm dummy.log
rm texput.log
rake aborted!
Errno::ENOENT: No such file or directory @ unlink_internal - texput.log
...

As you can see, "texput.log" appears twice what yields an error when you call a plain remove.

I already reported this 2.5 years ago and the only thing that happend was that I was critizied because my patch broke the unit test. I refused to fix the unit test as long as the unit test doesn't catch the actual bug. I wanted to report but not to be drawn into the quagmire of questionable code. That dispute seemed to be more important to the maintainers than the misbehaviour of the actual module. Maybe the old narrow-minded maintainers have resigned in the meantime.

@drbrain
Copy link
Member

drbrain commented Sep 22, 2017

You must be referring to #30

Can you update the tests to match the behavior you expect?

It is a common thing to update the tests when you find a bug so the bug does not re-appear. Typically this burden falls upon the submitter, as they are familiar with and care a lot about their bug, not with the maintainers who can have many other projects to maintain.

@drbrain
Copy link
Member

drbrain commented Sep 28, 2017

The built-in clean task doesn't have this issue because it also handles races in deleting files by checking if the file is already deleted when deletion fails.

Also, the test failures from #30 show there is are uniq and uniq! methods on Rake::FileList. This behavior is at least 14 years old, and you have thought most about it recently, so we would like to defer to your expertise in fixing any test changes that are needed.

@styd
Copy link
Contributor

styd commented Oct 15, 2017

Hi @BertramScharpf, I think the intended flow is to call on existing first before you iterate on them. But even then, the current implementation still shows duplicate file on the result.

That's why I propose #231.

If that's merged. You can iterate on them like this:

task :list do
  FileList[ "texput.*", "*.log"].existing.each { |f| puts "==== #{f}" }
end
task :clean do
  FileList[ "texput.*", "*.log"].existing.each { |f| rm f }
end

@drbrain
Copy link
Member

drbrain commented Oct 18, 2017

Now that #231 is merged I will close this because we don't know how many people depend on FileList behaving like an Array (where file names may be duplicated), which seems to be the original intent of FileList's behavior.

@drbrain drbrain closed this as completed Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants