yonicd / slickR

slick carousel htmlwidget for R
https://yonicd.github.io/slickR/
Other
159 stars 14 forks source link

Problem with slickR + shiny, when the xmlSVG-file becomes to large. #67

Open RobertOpitz opened 2 years ago

RobertOpitz commented 2 years ago

Hi there!

I'm using slickR with shiny, and I'm happy that this package exists. Unfortunatly, I encountered a strange error, when the necessary xml-Files become large. I traced the error down to the function slick_div_chr. There, it is tested if the input x is a regular file using utils::file_test('-f', x) . Here, x is the (by slickR processed) xml-Input, which is in this case a long string. If that string is to long (>= 1e5 characters) the underlying function file.info throws an error: Error in file.info(x, extra_cols = FALSE) : file name conversion problem -- name too long?.

As I can see, if the xml-Input is short enough, and processed by functions as_svg_character and hash_encode_url, then utils::file_test('-f', x) will always return FALSE, indicating the function file_test is only necessary with certain inputs.

As the function file_test is for a if-statement, maybe this can be solved by adding and extra argument, checking if file_test is actually necessary?

Best regards!

yonicd commented 2 years ago

thanks for pointing this out. you are welcome to submit a PR and I'll merge it into the main branch

RobertOpitz commented 2 years ago

I think, i solved the problem. I changed the function slick_div_chr in file dom_utils.R by adding and using an extra flag, wether the input x is a file. I also changed the function slick_div.xml_document and slick_div.character in file slick_div.R accordingly. I installed the changed package at my computer, and it worked there. You might find the files here: slickR_repair