From c85a53f630b70fc578cd1352591dbc956bb73162 Mon Sep 17 00:00:00 2001
From: Stephan Preibisch <stephan.preibisch@gmx.de>
Date: Thu, 24 Oct 2024 14:39:56 +0200
Subject: [PATCH] fix writing for google cloud

---
 src/main/java/util/URITools.java | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/main/java/util/URITools.java b/src/main/java/util/URITools.java
index 7890a603..23f0b8ee 100644
--- a/src/main/java/util/URITools.java
+++ b/src/main/java/util/URITools.java
@@ -123,7 +123,13 @@ else if ( URITools.isS3( xmlURI ) || URITools.isGC( xmlURI ) )
 			// fist make a copy of the XML and save it to not loose it
 			try
 			{
-				final String xmlFile = pb.protocol + pb.bucket + "/" + pb.rootDir + "/" + pb.file;
+				final String xmlFile;
+
+				if ( URITools.isS3( xmlURI ) )
+					xmlFile = pb.protocol + pb.bucket + "/" + pb.rootDir + "/" + pb.file;
+				else
+					xmlFile = pb.rootDir + "/" + pb.file;
+
 				if ( kva.exists( xmlFile ) )
 				{
 					int maxExistingBackup = 0;
@@ -169,7 +175,13 @@ else if ( URITools.isS3( xmlURI ) || URITools.isGC( xmlURI ) )
 				final XMLOutputter xout = new XMLOutputter( Format.getPrettyFormat() );
 				final String xmlString = xout.outputString( doc );
 
-				final PrintWriter pw = openFileWriteCloud( kva, pb.protocol + pb.bucket + "/" + pb.rootDir + "/" + pb.file );
+				String xmlPath;
+				if ( URITools.isS3( xmlURI ) )
+					xmlPath = pb.protocol + pb.bucket + "/" + pb.rootDir + "/" + pb.file;
+				else
+					xmlPath = pb.rootDir + "/" + pb.file;
+
+				final PrintWriter pw = openFileWriteCloud( kva, xmlPath );
 				pw.println( xmlString );
 				pw.close();
 			}