Skip to content

Commit

Permalink
fix shapefile zip management
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Apr 16, 2020
1 parent 8c4a36e commit 9d205d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/executeWorkflowJob.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ executeWorkflowJob <- function(config, jobdir = NULL){

for(entity in entities){

#if entity has data we copy data to job data dir
if(!is.null(entity$data) & !skipFileDownload) entity$copyDataToJobDir(config, jobdir)

#enrich metadata with dynamic properties
if(!is.null(entity$data)){
#data features
Expand All @@ -120,6 +117,9 @@ executeWorkflowJob <- function(config, jobdir = NULL){
#enrich entities with metadata (other properties)
entity$enrichWithMetadata(config)

#if entity has data we copy data to job data dir
if(!is.null(entity$data) & !skipFileDownload) entity$copyDataToJobDir(config, jobdir)

#run sequence of entity data actions (if any)
if(!is.null(entity$data)) {
if(entity$data$run){
Expand Down
5 changes: 3 additions & 2 deletions R/geoflow_entity.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,14 @@ geoflow_entity <- R6Class("geoflow_entity",
if(length(data.files)>0) zip(zipfile = paste0(basefilename,".zip"), files = data.files)
}else{
config$logger.info("Copying data local file(s): copying unzipped files to job data directory")
unzip(zipfile = srcFilename, unzip = getOption("unzip"))
data.files <- list.files(pattern = datasource_name)
data.files <- unzip(zipfile = srcFilename, unzip = getOption("unzip"))
if(length(data.files)>0) for(data.file in data.files){
file.copy(from = data.file, to = getwd())
fileparts <- unlist(strsplit(data.file,"\\."))
fileext <- fileparts[length(fileparts)]
file.rename(from = data.file, to = paste0(basefilename, ".", fileext))
}
unlink(srcFilename)
data.files <- list.files(pattern = basefilename)
if(length(data.files)>0) zip(zipfile = paste0(basefilename,".zip"), files = data.files)
}
Expand All @@ -363,6 +363,7 @@ geoflow_entity <- R6Class("geoflow_entity",
config$logger.info("Writing entity data features to job data directory!")
switch(self$data$sourceType,
"shp" = {
unlink(paste0(basefilename, ".zip"))
sf::st_write(self$data$features, paste0(basefilename, ".shp"), delete_dsn = FALSE)
data.files <- list.files(pattern = basefilename)
zip(zipfile = paste0(basefilename, ".zip"), files = data.files)
Expand Down

0 comments on commit 9d205d8

Please sign in to comment.