Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Files.move() is not moving all the files from a Azure File Share volume mounted as PV in a spring-boot app

$
0
0

We have a spring-boot app which is a Camunda External Task client services deployed on Azure AKS.For this app we have mounted Azure File Share as a PV.Now, a service in the app is designed to move all the files from a sub-folder in the mounted volume to another sub-folder.For this, I have used Files.move() function of java-17 which is running in a for-each loop for iterating from the folder.

try (Stream<Path> folder = Files.list(Path.of(source))) {      Path destinationPath = Files.createDirectories(Paths.get(destination));      folder          .map(Path::toFile)          .forEach(sourceFile -> fileUtil.moveFile(source, sourceFile, destinationPath));    }    void moveFile(String source, File sourceFile, Path destinationPath) {        Path destFile = destinationPath.resolve(Path.of(source).relativize(sourceFile.toPath()));        try {          Files.move(sourceFile.toPath(), destFile, StandardCopyOption.REPLACE_EXISTING);        } catch (IOException e) {          throw new CustomException("file " + sourceFile +" not moved to " + destinationPath +" folder", e);        }      }

Now, the issue is, all files are not getting moved, for e.g if I keep around 50 files, only 31 gets moved.Also it seems the issue seems specifically to the path which is mounted as volume, because I tried moving files from /app directory and it worked fine.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>