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 symlink regression #541

Merged
merged 5 commits into from
Sep 10, 2016
Merged

Fix symlink regression #541

merged 5 commits into from
Sep 10, 2016

Conversation

robwise
Copy link
Contributor

@robwise robwise commented Sep 5, 2016

This change is Reviewable

@robwise
Copy link
Contributor Author

robwise commented Sep 5, 2016

Possibly related: #537 (comment)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 82.534% when pulling 642ba75 on rob/fix-symlink-regression into ebf079b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 82.534% when pulling 642ba75 on rob/fix-symlink-regression into ebf079b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 82.534% when pulling a17f7fd on rob/fix-symlink-regression into ebf079b on master.

@dzirtusss
Copy link
Contributor

Reviewed 3 of 3 files at r1, 3 of 3 files at r2.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


lib/react_on_rails/assets_precompile.rb, line 40 [r2] (raw file):

      if file_or_symlink_exists_at_path?(symlink_path)
        puts "React On Rails: Removing existing invalid symlink or file #{symlink_path}"
        `rm -f "#{symlink_path}"`

I think we should not use any OS calls in gem at all. Why not to change to FileUtils or smth? Some previous errors were because somebody tried to use filenames with spaces and all that process get broken.


Comments from Reviewable

@justin808
Copy link
Member

Review status: all files reviewed at latest revision, 1 unresolved discussion.


lib/react_on_rails/assets_precompile.rb, line 40 [r2] (raw file):

Previously, dzirtusss (Sergey Tarasov) wrote…

I think we should not use any OS calls in gem at all. Why not to change to FileUtils or smth? Some previous errors were because somebody tried to use filenames with spaces and all that process get broken.

I'm OK with that change, @dzirtusss

Comments from Reviewable

When we changed this method in #513 we introduced a regression due
to the difference between calling the shell's `ln -s` command and
using Ruby's `File.symlink` command.

Specifically, the former would not error if the symlink already
existed, while the latter did throw an error. Because it is
sometimes the case that the symlink will already exist, throwing
in this case is not desirable.

This should have not been a problem, however, as this scenario
was supposed to have been properly handled, but that code was not
correct. This commit fixes that code.
@robwise
Copy link
Contributor Author

robwise commented Sep 5, 2016

Review status: 2 of 3 files reviewed at latest revision, 1 unresolved discussion.


lib/react_on_rails/assets_precompile.rb, line 40 [r2] (raw file):

Previously, justin808 (Justin Gordon) wrote…

I'm OK with that change, @dzirtusss

Done.

Comments from Reviewable

@justin808
Copy link
Member

Overall good. Couple questions. Plus, can we get a couple unit tests that show the changes?


Reviewed 2 of 3 files at r1, 1 of 4 files at r3.
Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


lib/react_on_rails/assets_precompile.rb, line 31 [r3] (raw file):

      # File.exist?(symlink_path) will check the file the sym is pointing to is existing
      # File.lstat(symlink_path).symlink? confirms that this is a symlink
      valid_symlink_already_exists = File.exist?(symlink_path) && File.lstat(symlink_path).symlink?

Can this be a method and end with ?? and have a unit test?


lib/react_on_rails/assets_precompile.rb, line 85 [r3] (raw file):

          # We want the gz ones as well if they exist
          if File.exist?(@assets_path.join("#{rails_digested_filename}.gz"))

Why do we need to check this here?


lib/react_on_rails/assets_precompile.rb, line 123 [r3] (raw file):

    private

    def file_or_symlink_exists_at_path?(path)

unit test?


Comments from Reviewable

@robwise
Copy link
Contributor Author

robwise commented Sep 6, 2016

Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


lib/react_on_rails/assets_precompile.rb, line 31 [r3] (raw file):

Previously, justin808 (Justin Gordon) wrote…

Can this be a method and end with ?? and have a unit test?

I didn't write this, I just renamed the variable

lib/react_on_rails/assets_precompile.rb, line 85 [r3] (raw file):

Previously, justin808 (Justin Gordon) wrote…

Why do we need to check this here?

it'll throw if you try to symlink a file that doesn't exist, so all of the tests you wrote would fail without this

lib/react_on_rails/assets_precompile.rb, line 123 [r3] (raw file):

Previously, justin808 (Justin Gordon) wrote…

unit test?

you can't unit test private methods, not to mention I don't see the need to unit test whether core Ruby methods work

Comments from Reviewable

@justin808
Copy link
Member

@robwise or @dzirtusss Please confirm my last commit. I changed the things I commented on.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 82.924% when pulling 168f3c8 on rob/fix-symlink-regression into ebf079b on master.

@@ -62,6 +62,48 @@ module ReactOnRails
end.to raise_exception(AssetsPrecompile::SymlinkTargetDoesNotExistException)
end
end

it "creates a proper symlink when a file exists at destination" do
Copy link
Contributor Author

@robwise robwise Sep 8, 2016

Choose a reason for hiding this comment

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

you should specify which destination you are talking about

@justin808
Copy link
Member

Review status: 1 of 3 files reviewed at latest revision, 12 unresolved discussions.


spec/react_on_rails/assets_precompile_spec.rb, line 66 [r4] (raw file):

Previously, robwise (Rob Wise) wrote…

you should specify which destination you are talking about

destination is where you want to create the symlink

what's a better word for this?

Here's the docs:

symlink(old_name, new_name) → 0 click to toggle source
Creates a symbolic link called new_name for the existing file old_name. Raises a NotImplemented exception on platforms that do not support symbolic links.

suggestion?


spec/react_on_rails/assets_precompile_spec.rb, line 77 [r4] (raw file):

Previously, robwise (Rob Wise) wrote…

is it a valid symlink or invalid symlink? It doesn't do anything if it's valid, just outputs a message

context "when there is already a valid symlink in place" do

   it "outputs a message saying that it need not perform any action" do
@robwise you're thinking of the calling code that does this check. This method doesn't care.

spec/react_on_rails/assets_precompile_spec.rb, line 83 [r4] (raw file):

Previously, robwise (Rob Wise) wrote…

I don't get what's going on here compared to your test description

??

spec/react_on_rails/assets_precompile_spec.rb, line 89 [r4] (raw file):

Previously, robwise (Rob Wise) wrote…

Unnecessary, this is a TempFile

Not true in this case, as I created a symlink.

spec/react_on_rails/assets_precompile_spec.rb, line 105 [r4] (raw file):

Previously, robwise (Rob Wise) wrote…

why are you doing this, it's a TempFile?

Not true in this case, as I created a symlink.

Comments from Reviewable

@justin808 justin808 merged commit 211fed0 into master Sep 10, 2016
@justin808 justin808 deleted the rob/fix-symlink-regression branch September 10, 2016 02:47
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 82.924% when pulling d32a8cb on rob/fix-symlink-regression into ebf079b on master.

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

Successfully merging this pull request may close these issues.

4 participants