{"action":"closed","issue":{"url":"https://api.github.com/repos/PredictiveEcology/reproducible/issues/32","repository_url":"https://api.github.com/repos/PredictiveEcology/reproducible","labels_url":"https://api.github.com/repos/PredictiveEcology/reproducible/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/PredictiveEcology/reproducible/issues/32/comments","events_url":"https://api.github.com/repos/PredictiveEcology/reproducible/issues/32/events","html_url":"https://github.com/PredictiveEcology/reproducible/issues/32","id":335201121,"node_id":"MDU6SXNzdWUzMzUyMDExMjE=","number":32,"title":"prepInputs is returning wrong results","user":{"login":"tati-micheletti","id":33500569,"node_id":"MDQ6VXNlcjMzNTAwNTY5","avatar_url":"https://avatars2.githubusercontent.com/u/33500569?v=4","gravatar_id":"","url":"https://api.github.com/users/tati-micheletti","html_url":"https://github.com/tati-micheletti","followers_url":"https://api.github.com/users/tati-micheletti/followers","following_url":"https://api.github.com/users/tati-micheletti/following{/other_user}","gists_url":"https://api.github.com/users/tati-micheletti/gists{/gist_id}","starred_url":"https://api.github.com/users/tati-micheletti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tati-micheletti/subscriptions","organizations_url":"https://api.github.com/users/tati-micheletti/orgs","repos_url":"https://api.github.com/users/tati-micheletti/repos","events_url":"https://api.github.com/users/tati-micheletti/events{/privacy}","received_events_url":"https://api.github.com/users/tati-micheletti/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-24T18:29:43Z","updated_at":"2018-11-15T23:20:17Z","closed_at":"2018-11-15T23:20:17Z","author_association":"CONTRIBUTOR","body":"When working inside a module, I have 2 files with similar names (i.e. \"C2C_change_**year**.tif\" and \"C2C_change_**type**.tif\") being called with prepInputs to be processed (cropped and masked to a rasterToMatch and a studyArea). Both files being returned are identical (they are not in memory, and the path to them is the same, always pointing to the first of call of prepInputs, independently of which one of the two it is). If I call the \"year\" one first, prepInputs cache returns \"year\" for the second file, and vice versa. Do we have a limited amount of characters on the file's name? I can work around it by not using prepInputs, but I want to use the function.  Below the exact code I am using for it. It is not reproducible because I am hitting other problems such as not being able to open/extract the zip file in a temporary folder... =/\r\nWhen I try it with useCache = FALSE, it also doesn't work.\r\n\r\n```\r\nsim$disturbanceYear <- prepInputs(targetFile = file.path(dataPath(sim), \"C2C_change_year.tif\"),\r\n                                        destinationPath = dataPath(sim),\r\n                                        useCache = FALSE, # tried turning it on and off\r\n                                        # archive = \"C2C_change_year.zip\",\r\n                                        # alsoExtract = \"similar\",\r\n                                        # url = \"https://opendata.nfis.org/downloads/forest_change/C2C_Change_Year.zip\",\r\n                                        rasterToMatch = sim$birdDensityRasters[[1]],\r\n                                        studyArea = sim$rP)\r\n      \r\n      sim$disturbanceType <- prepInputs(targetFile = file.path(dataPath(sim), \"C2C_change_type.tif\"), \r\n                                        destinationPath = dataPath(sim),\r\n                                        useCache = FALSE, # tried turning it on and off\r\n                                        # archive = \"C2C_change_type.zip\",\r\n                                        # alsoExtract = \"similar\",\r\n                                        # url = \"https://opendata.nfis.org/downloads/forest_change/C2C_Change_Type.zip\",\r\n                                        rasterToMatch = sim$birdDensityRasters[[1]],\r\n                                        studyArea = sim$rP)\r\n```\r\n\r\nAnd this is my failed attempt to reproduce the above outside a module:\r\n\r\n```dir.create(file.path(getwd(), \"testingPrepInputs\"), showWarnings = FALSE)\r\ntmpDir <- file.path(getwd(), \"testingPrepInputs\")\r\n\r\nset.seed(1234)\r\nrP <- SpaDES.tools::randomPolygon(x = matrix(c(-93.028935, 50.271979), ncol = 2), \r\n                                  hectares = 5000000)\r\nbirdSp <- c(\"BBWA\", \"YRWA\")\r\nbirdDensityRasters <- lapply(X = birdSp, FUN = function(x){\r\n  ras <- reproducible::prepInputs(targetFile = file.path(tmpDir, paste0(\"/\", x, \"_currmean.asc\")),\r\n                    archive = paste0(x, \"_current.zip\"),\r\n                    url = paste0(\"https://s3-us-west-2.amazonaws.com/bam-databasin-climatechangepredictions/climatepredictions-ascii/\",\r\n                                 x, \"_current.zip\"),\r\n                    destinationPath = tmpDir,\r\n                    studyArea = rP)\r\n})\r\n\r\ndisturbanceYear <- reproducible::prepInputs(targetFile = file.path(tmpDir, \"C2C_change_year.tif\"),\r\n                                            url = \"https://opendata.nfis.org/downloads/forest_change/C2C_Change_Year.zip\",\r\n                                            archive = \"C2C_change_year.zip\",\r\n                                            alsoExtract = \"similar\",\r\n                                            rasterToMatch = birdDensityRasters[[1]],\r\n                                            destinationPath = tmpDir,\r\n                                            studyArea = rP)\r\n\r\ndisturbanceType <- reproducible::prepInputs(targetFile = file.path(tmpDir, \"C2C_change_type.tif\"),\r\n                                            archive = \"C2C_change_type.zip\",\r\n                                            alsoExtract = \"similar\",\r\n                                            url = \"https://opendata.nfis.org/downloads/forest_change/C2C_Change_Type.zip\",\r\n                                            rasterToMatch = birdDensityRasters[[1]],\r\n                                            destinationPath = tmpDir,\r\n                                            studyArea = rP)\r\n```\r\n@eliotmcintire Maybe this has something to do with the grep problem you fixed in prepInputs?"}}
{"actor":{"display_login":"tati-micheletti"}}