thomasp85 / shinyFiles

A shiny extension for server side file access
195 stars 47 forks source link

getVolumes hangs when drive is no longer available #155

Closed see24 closed 2 years ago

see24 commented 3 years ago

This is a very specific issue that might not come up for many people but it was really annoying for me so thought I would put it out there.

getVolumes was working fine in my app and then the app stopped working completely which I eventually traced to getVolumes()() hanging for a long time. I eventually figured out that this was happening because I had disconnected from my VPN to connect to my work network. This meant that network drives that were mapped when I logged in to the VPN and still to show up in the file explorer(but they never load and hang in the windows explorer too) were being looked for by getVolumes and that is what made it hang.

I added R.utils::withTimeout around the getVolumes call so that I don't do this to myself again, but wondering if it would make sense to add a timeout with in getVolumes?

vnijs commented 3 years ago

Thanks for reporting @see24. I made a change to the commands on Windows that scan for drives (see link below). My hope is that this will skip drives that do not respond within 3 seconds and then move on to other drives.

I don't have any network drives on Windows to fully test this out so could you try it and let me know?

To install the development version of shinyFiles please use the command below:

remotes::install_github("thomasp85/shinyFiles", upgrade="never")

https://github.com/thomasp85/shinyFiles/commit/f875ad1412de82694f519733d03302f7244d1839#diff-03e4b0fc41a86a656bef22b0ca136edf24dc52190ba342aafd7eca8ede337e30R82-R86

see24 commented 3 years ago

While connected to the VPN I got this warning message: "Warning in system(paste(wmic, "/FAILFAST:3000 logicaldisk get Caption"), : running command 'C:\WINDOWS\System32\Wbem\WMIC.exe /FAILFAST:3000 logicaldisk get Caption' had status 44003" But it all worked fine as before. When I disconnected from the VPN and tried again the app loaded okay but when I open the file selector it is blank and I cannot navigate to any files. There is no error message so it is not clear what has gone wrong. Then after 3 minutes the folder showed up and I was able to select a file and it all worked.

vnijs commented 3 years ago

Thanks for testing this out! I made a change that will (1) hopefully avoid the warning being printed and (2) fail faster if VPN is not on. See commit linked below. Can you try again? Also, feel free to make edits to R/aaa.R and report if you find settings for /FAILFAST that work best. I think this is the best path to go because it should still return other drives even if one network drive is not accessible. Unfortunately I don't have any way to test this so I have to rely on your input. Thanks!

https://github.com/thomasp85/shinyFiles/commit/3ed2746c7612bf8587473aa907cd7759527a4222

vnijs commented 3 years ago

Minor update. Use the code below to install the latest version.

remotes::install_github("thomasp85/shinyFiles", upgrade="never")

https://github.com/thomasp85/shinyFiles/blob/master/R/aaa.R#L82-L86

vnijs commented 3 years ago

@see24 Can you try this out? Use the code below to install the latest version.

remotes::install_github("thomasp85/shinyFiles", upgrade="never")

https://github.com/thomasp85/shinyFiles/blob/master/R/aaa.R#L82-L86

see24 commented 2 years ago

Works well now! The first time connecting after disconnecting from VPN it takes a little while for the file selector to load but works well and it is not too long. Thanks for fixing this and sorry I took so long to test it!

vnijs commented 2 years ago

Thanks @see24 !