From 49cbacb1bd371b4ff4781d58c3eee9be2e313187 Mon Sep 17 00:00:00 2001 From: Emile Sonneveld Date: Mon, 14 Oct 2024 16:30:26 +0200 Subject: [PATCH] Use FileChannel force to make sure the fusemount writes the tiff files before the executor gets closed. https://github.com/Open-EO/openeo-geotrellis-extensions/issues/329 --- .../main/scala/org/openeo/geotrellis/geotiff/package.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openeo-geotrellis/src/main/scala/org/openeo/geotrellis/geotiff/package.scala b/openeo-geotrellis/src/main/scala/org/openeo/geotrellis/geotiff/package.scala index 99a00424..ea7f33b4 100644 --- a/openeo-geotrellis/src/main/scala/org/openeo/geotrellis/geotiff/package.scala +++ b/openeo-geotrellis/src/main/scala/org/openeo/geotrellis/geotiff/package.scala @@ -32,6 +32,7 @@ import software.amazon.awssdk.services.s3.model.PutObjectRequest import spire.math.Integral import spire.syntax.cfor.cfor +import java.nio.channels.FileChannel import java.nio.file.{Path, Paths} import java.time.Duration import java.time.format.DateTimeFormatter @@ -838,6 +839,10 @@ package object geotiff { } else { geoTiff.write(path, optimizedOrder = true) + // Call fsync on the parent path to assure the fusemount is up-to data: + val channel = FileChannel.open(Path.of(path)) + // Ensure that all changes to the file are written to disk + channel.force(true) // The equivalent of Python's os.fsync path }