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

symlinks not synced #385

Closed
EthraZa opened this issue Mar 5, 2021 · 15 comments
Closed

symlinks not synced #385

EthraZa opened this issue Mar 5, 2021 · 15 comments

Comments

@EthraZa
Copy link

EthraZa commented Mar 5, 2021

I'm using minify as

minify --match '\.(css|html|js|json)$' -sar dev/ -o prod/

The match files are getting minified, the other files are getting synced, but the symlinks are been ignored and my prod is getting non functional as a result.
There is a way to sync symlinks as well?

@tdewolff
Copy link
Owner

tdewolff commented Mar 7, 2021

Yes that could be supported. Do you want to copy the symlink itself, or do you want to treat it like a file/directory (that should be traversed)?

@EthraZa
Copy link
Author

EthraZa commented Mar 8, 2021

Copy the synlinks itself, since I have things like:

awesome-lib-v1.0/
awesome-lib-v1.1/
awesome-lib-latest -> awesome-lib-v1.1/

@tdewolff
Copy link
Owner

tdewolff commented Mar 9, 2021

Can you check if this works for you? I've pushed the new feature!

@EthraZa
Copy link
Author

EthraZa commented Mar 9, 2021

No, looks like it got broken now.

$ ~/go/bin/minify --version
minify v2.9.13-14-gf6339e8

$ uname -a
Linux allan-inspiron5675 5.11.2-1-MANJARO #1 SMP PREEMPT Fri Feb 26 12:17:53 UTC 2021 x86_64 GNU/Linux

Without -p:

$ ~/go/bin/minify --match '\.(css|html|js|json)$' -sar ./dev -o ./prod
ERROR: stat lib/libweb/ext-3.4.0/ext-core: no such file or directory

$ ls -l dev/lib/libweb/ext-3.4.0/ext-core
lrwxrwxrwx 1 allan allan 8 fev 24 17:45 dev/lib/libweb/ext-3.4.0/ext-core -> ext-core
(blinking red)

Yeh, it's a symlink pointing to a missing file, or worst yet, pointing to itself. :)

With -p:

$ ~/go/bin/minify --match '\.(css|html|js|json)$' -sarp ./dev -o ./prod
ERROR: rename admin/js/Conf.js admin/js/Conf.js.bak: no such file or directory
... "lots of similar errors" ...

$ ls -l prod
total 0

@tdewolff
Copy link
Owner

tdewolff commented Mar 9, 2021

Yes, you were a little faster than I expected! Haha, please try again, the no such file errors should be fixed.

Remember that the target of the symlink doesn't change (this is similar to the cp -P functionality). That is, if you have src/link => file, you'll get dst/link => file and not dst/link => ../src/file if you get what I mean.

@EthraZa
Copy link
Author

EthraZa commented Mar 9, 2021

Hi!

$ ~/go/bin/minify --version
minify v2.9.13-17-g273dcd6

Without -p:
I let this erratic symlink there, pointing to itself, just to test minify (:/).
But I don't get why it's exploding if there is no -p. The stable 2.9.13 just ignores it.

$ ~/go/bin/minify --match '\.(css|html|js|json)$' -sar ./dev -o ./hml 
ERROR: stat dev/lib/libweb/ext-3.4.0/ext-core: too many levels of symbolic links

With -p:
Now it worked, mostly. I noticed just 2 things with this one error throwed.
1- It didn't copied this one link, not sure why..
2- The original file was copied, but the file permission was not honored, changing from 755 to 644.

$ ~/go/bin/minify --match '\.(css|html|js|json)$' -sarp ./dev -o ./hml 
ERROR: symlink ../nesbot/carbon/bin/carbon hml/php/libs/vendor/bin/carbon: no such file or directory

$ ls -l dev/php/libs/vendor/bin/carbon
lrwxrwxrwx 1 allan allan 27 fev 24 17:46 dev/php/libs/vendor/bin/carbon -> ../nesbot/carbon/bin/carbon*
$ ls -l dev/php/libs/vendor/nesbot/carbon/bin/carbon
-rwxr-xr-x 1 allan allan 378 fev 24 17:46 dev/php/libs/vendor/nesbot/carbon/bin/carbon*

$ ls -l hml/php/libs/vendor/nesbot/carbon/bin/carbon
-rw-r--r-- 1 allan allan 378 mar  9 20:01 hml/php/libs/vendor/nesbot/carbon/bin/carbon
$ ls -l hml/php/libs/vendor/bin/carbon
ls: cannot access 'hml/php/libs/vendor/bin/carbon': no such file or directory

@tdewolff
Copy link
Owner

tdewolff commented Mar 9, 2021

Thanks again for the feedback. The recursive symlink is probably not something we need to fix, cp gives the same error, and at the end the isn't a real file that we can minify, so why dereference it?

The other two issue, I don't follow 1), can you please explain it better so I can recreate he issue? And for 2) this is probably a separate issue, as we're not preserving file permissions and ownership anywhere (but we should).

@tdewolff
Copy link
Owner

tdewolff commented Mar 9, 2021

Regarding ownership and file permissions, doesn't seem like we can set those for symlinks in Go...it only applies to its target.

@EthraZa
Copy link
Author

EthraZa commented Mar 12, 2021

Replicating the issue:
(copy and paste into a nix shell - and change the minify path)

$ mkdir -p dev/real dev/link; cd dev/link/; echo "console.log('Minify...'); console.log('me.');" > ../real/tst.js; ln -s ../real/tst.js; cd ../../; ~/go/bin/minify --match '\.(css|html|js|json)$' -sarp ./dev -o ./tst
false
ERROR: symlink ../real/tst.js tst/link/tst.js: no such file or directory

@tdewolff
Copy link
Owner

It wasn't creating all the directories if they were missing, now it should work!

@EthraZa
Copy link
Author

EthraZa commented Mar 14, 2021

Looks like it's broken.

$ ~/go/bin/minify --version
minify v2.9.13-24-g81aab62

$ ~/go/bin/minify --match '\.(css|html|js|json)$' -sarpv dev/ -o tst
infer mimetype from file extensions
minify to output directory tst/
ERROR: open dev/: invalid argument

$ ~/go/bin/minify --match '\.(css|html|js|json)$' -sarv dev/ -o tst
infer mimetype from file extensions
minify to output directory tst/
ERROR: open dev/: invalid argument

tdewolff added a commit that referenced this issue Mar 15, 2021
@tdewolff
Copy link
Owner

Ah sorry, how about now?

@EthraZa
Copy link
Author

EthraZa commented Mar 15, 2021

Now it is working.

$ ~/go/bin/minify --version
minify v2.9.14-1-g1635632

$ minify ./dev -o tst

The only difference I noticed was this one:
v2.9.13: will create ./tst/file.js

v2.9.14-1-g1635632: will create ./tst/dev/file.js
and I was unable to get it act like the older version.

@tdewolff
Copy link
Owner

Yes, this is because this way it reflects better how cp works. You can use minify ./dev/. -o tst to get the original functionality where the dev directory will not be created.

@EthraZa
Copy link
Author

EthraZa commented Mar 15, 2021

Oh sorry, dumb of me, just skipped the dot way in the tests.
So, looks kike it's good now. Thank you.

  • My Manjaro install just prompted to update it to 2.9.14-1. Nice and quick job! ;)

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