diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSystemService.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSystemService.java index 73ab08ee..2ba0a585 100644 --- a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSystemService.java +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/filesharing/FileSystemService.java @@ -45,8 +45,10 @@ private boolean writeStreamToFile(String fileName, InputStream content, String q try { LOG.info("Writing query {} to file: {}", queryId, filePath); - if (!Files.exists(dirPath)) { - Files.createDirectory(dirPath); + synchronized (dirPath) { + if (!Files.exists(dirPath)) { + Files.createDirectory(dirPath); + } } return Files.copy(content, filePath) > 0; } catch (IOException e) {