I have a download button, which will generate some files, pack to a zip then let user download it. It's something like this:
content = function(file) {
save_shapefiles <- function(hrange_list, ud_levels) {...}
cat("function started")
build_shapefile_zip(file, save_shapefiles(hrange_list, ud_levels))
cat("function ended")
}
I found the build_shapefile_zip
actually was run twice, thus create two set of temp directories and files. The print message proved that
- After clicking download button, there is this file dialog asking for file name
- Now the
build_shapefile_zip
function has run once. - Accept the default file name, save file, close the dialog. The function run the 2nd time.
This seemed to be specific to RStudio Mac builtin browser, which have an empty browser window. Run app in chrome will download the file directly (without asking file name), and only run function once.
This should be a bug of safari, but I'm wondering if it can be fixed from RStudio/Shiny side.