Skip to content

Commit

Permalink
Notify user if pathname doesn't exist or if it's a file instead of a …
Browse files Browse the repository at this point in the history
…folder, closes #39
  • Loading branch information
nuno-agostinho committed Jul 7, 2016
1 parent 61d3c0c commit 2f71fa1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions R/data_local.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ setLocalData <- function(input, output, session, replace=TRUE) {
sub <- dir(folder, full.names=TRUE)[dir.exists(
dir(folder, full.names=TRUE))]

startProgress("Searching inside the folder...",
divisions=1 + length(sub))
startProgress("Searching inside the folder...", divisions=1 + length(sub))
loaded <- loadFirehoseFolders(sub, ignore, updateProgress)
data <- setNames(list(loaded), category)

Expand Down Expand Up @@ -99,6 +98,24 @@ localDataServer <- function(input, output, session, active) {

# If data is loaded, let user replace or append to loaded data
observeEvent(input$acceptFile, {
folder <- input$localFolder
if (!dir.exists(folder)) {
if (file.exists(folder)){
# Asking for a folder, not a file
errorModal(session, "Folder not found",
"The path is directing to a file, but only folders are",
"accepted. Please, insert the path to a folder.",
modalId="localDataModal")
} else {
# Folder not found
errorModal(session, "Folder not found",
"Check if path is correct.",
modalId="localDataModal")
}
enable("acceptFile")
return(NULL)
}

if (!is.null(getData()))
loadedDataModal(session,
"localDataModal",
Expand Down

0 comments on commit 2f71fa1

Please sign in to comment.