Commit 6ee8e656 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Fixed concurrency issue on multiple files upload

parent 99dd1b35
Loading
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -83,11 +83,17 @@ public class PutFileController {

        File file = path.toFile();

        /**
         * This block must be synchronized, to avoid concurrency issues when
         * multiple files are uploaded to a new folder in parallel.
         */
        synchronized (this) {
            if (!file.getParentFile().exists()) {
                if (!file.getParentFile().mkdirs()) {
                    throw new IllegalStateException("Unable to create parent folder: " + file.getParentFile().getAbsolutePath());
                }
            }
        }

        Files.copy(is, file.toPath());
    }