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

Have MyDocuments and Desktop in getvolumes (with solution) #52

Closed
zeehio opened this issue Nov 3, 2016 · 1 comment
Closed

Have MyDocuments and Desktop in getvolumes (with solution) #52

zeehio opened this issue Nov 3, 2016 · 1 comment

Comments

@zeehio
Copy link
Contributor

zeehio commented Nov 3, 2016

Right now to have MyDocuments and Desktop as volumes on Windows machines I am using this.

(Note that this depends on powershell being available)

  myVolumes <- function() {
    if (.Platform$OS.type == "windows") {
      extra_volumes <- c(Desktop = system2("powershell", "[Environment]::GetFolderPath('Desktop')", stdout = TRUE),
                         MyDocuments = system2("powershell", "[Environment]::GetFolderPath('MyDocuments')", stdout = TRUE),
                         UserProfile = system2("powershell", 'echo $env:USERPROFILE', stdout = TRUE))
    } else {
      extra_volumes <- c()
    }
    c(extra_volumes, shinyFiles::getVolumes()())
  }

And then

  shinyFileChoose(input, 'whatever', roots = mygetVolumes)

Maybe this would be a nice addition to getVolumes.

Currently getVolumes returns a function that is called very often, to see if there are updates on any volume (new USB attached, etc). This has a strong performance penalty on Windows.

To address the performance penalty it would be useful to have a refresh button next to the volume selection menu so getVolumes is only called every once in a while.

As a workaround, if you don't care about "new attached USB drives" you can use:

  list_of_volumes <- mygetVolumes()
  shinyFileChoose(input, 'whatever', roots = list_of_volumes)
@thomasp85
Copy link
Owner

These system level niceties would indeed be nice, but I'm not going to put a powershell dependency in for the sake of that.

I was unaware of the penalty hit in Windows. The user/developer is free to set the update frequency so it should be easy to control IMO. Otherwise just use a constant vector as you suggest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants