Skip to content

Commit

Permalink
catch for writing subdataset-based rasters over FUSE
Browse files Browse the repository at this point in the history
  • Loading branch information
sllynn committed Sep 30, 2024
1 parent 4dc9bb6 commit 225f95d
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -628,14 +628,25 @@ case class MosaicRasterGDAL(
def writeToPath(newPath: String, dispose: Boolean = true): String = {
if (isSubDataset) {
val driver = raster.GetDriver()
val ds = driver.CreateCopy(newPath, this.flushCache().getRaster, 1)

//test to see if path is in a fuse location
val outPath = if (PathUtils.isFuseLocation(newPath)) {
PathUtils.createTmpFilePath(getRasterFileExtension)
} else {
newPath
}

val ds = driver.CreateCopy(outPath, this.flushCache().getRaster, 1)
if (ds == null) {
val error = gdal.GetLastErrorMsg()
throw new Exception(s"Error writing raster to path: $error")
}
ds.FlushCache()
ds.delete()
if (dispose) RasterCleaner.dispose(this)
if (outPath != newPath) {
Files.move(Paths.get(outPath), Paths.get(newPath), StandardCopyOption.REPLACE_EXISTING)
}
newPath
} else {
val thisPath = Paths.get(this.path)
Expand Down

0 comments on commit 225f95d

Please sign in to comment.