getJSON cache raises 'file name too long'


#1

(Mix between feature and support, thought best to post here)

When getting JSON data from an API with a very long url, the download runs fine, but if the cache path is too long, a ‘file name too long’ error is raised. I’m reasonably sure this is the OS not hugo, but this is certainly the right place to raise this!

Obviously this is a reasonably niche issue, but still one all the same, as my site wont build. Whilst i dont know how the cache for this works in hugo, I have come up with a potential solution.

If rather than using the full URL as the filename, you instead used a hash (doesnt matter which), then the filename will be far shorter, and a uniform length. Yes this does make finding a cache file much harder for a user, but for hugo to find it, it’s a minimal computational step extra.

Another alternative would be to store all cache items in a single file, but that feels a bit too weird, and would likely increase the memory footprint.

Open to suggestions, but saving the url as the filename just feels like a massive hack IMO.


#2

A hash as key sounds reasonable, but it would be good if you could create an issue on GitHub to track this.


#3

Commented here incase a discussion was needed, or i’d missed a setting.

Issue created: https://github.com/gohugoio/hugo/issues/3690


#4

Try using “Long Path Tool” program that fixes path too long issues with simplicity.


#5

try Long Path Tool,it’s very helping in long file name


#6

This issue should be fixed in the latest Hugo release, v0.26.