Open bbaugher opened 7 years ago
Sad trombone dot gif, didn't think of this. I should probably check what the limit on Windows is too.
Because you filed the bug you get to have an opinion, switch to a hash for anything over 255 chars (or whatever the max on Windows is)? It won't be as nicely readable but should be better than nothing.
I'm not totally sure I understand what we get out of adding anything like that to the file name.
We need some kind of unique name for the cache file, the goal with Base64 was to make something that could be reversed to the original URL during manual debugging if needed, while a hash could not be, but is fixed-length.
I would have thought converting URL to the filename would be sufficient for most if not all. Generating a hash seems simplest. I don't think you lose a lot from doing that
I did think that, but as you noticed this can make invalid filenames when very long ;-)
I meant converting http://www-eu.apache.org/dist/kafka/0.10.1.0/kafka_2.10-0.10.1.0.tgz
into kafka_2.10-0.10.1.0.tgz
.
Unfortunately that is not unique enough, I ran into problems early on with downloads of the same name but in different folders.
Anyways, I'll fix this up shortly.
What about hashing the URL with SHA1? We are also running into this problem. I can submit a PR if this solution is acceptable.
I changed this a while ago to use a base64 of the resource name and only the last path component of the URL, you're still hitting something too long though?
Oh yes. Especially with consul-template. Why not just use Digest::SHA256.base64digest
?
An example:
[2017-05-05T16:34:45+00:00] ERROR: consul_template_installation[0.16.0] (test_consul_template::default line 19) had an error: Errno::ENAMETOOLONG: poise_archive[https://releases.hashicorp.com/consul-template/0.16.0/consul-template_0.16.0_linux_amd64.zip] (/opt/kitchen/cache/cookbooks/consul_template/libraries/consul_template_installation_binary.rb line 42) had an error: Errno::ENAMETOOLONG: remote_file[/opt/kitchen/cache/aHR0cHM6Ly9yZWxlYXNlcy5oYXNoaWNvcnAuY29tL2NvbnN1bC10ZW1wbGF0ZS8wLjE2LjAvY29uc3VsLXRlbXBsYXRlXzAuMTYuMF9saW51eF9hbWQ2NC56aXA_consul-template_0.16.0_linux_amd64.zip] (/opt/kitchen/cache/cookbooks/poise-archive/files/halite_gem/poise_archive/archive_providers/base.rb line 84) had an error: Errno::ENAMETOOLONG: File name too long @ utime_internal - /opt/kitchen/cache/aHR0cHM6Ly9yZWxlYXNlcy5oYXNoaWNvcnAuY29tL2NvbnN1bC10ZW1wbGF0ZS8wLjE2LjAvY29uc3VsLXRlbXBsYXRlXzAuMTYuMF9saW51eF9hbWQ2NC56aXA_consul-template_0.16.0_linux_amd64.zip
Ahh okay, so the part of the workaround I didn't mention is you can use the path
property directly rather than the resource name for the long URL, I'll fix that in the next release to be smarter though.
Looks like the code generates a unique name for the cached file by converting the URL into Base64. This can then easily go over the 255 character file name limit if the URL is long enough