simonetripodi commented on a change in pull request #16: SLING-8630 - Prevent 
the Converter from overwritting an existing POM …
URL: 
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/16#discussion_r315266597
 
 

 ##########
 File path: 
src/main/java/org/apache/sling/feature/cpconverter/artifacts/DefaultArtifactsDeployer.java
 ##########
 @@ -89,8 +89,12 @@ public void deploy(ArtifactWriter artifactWriter, 
ArtifactId id) throws IOExcept
 
         targetFile = new File(targetDir, String.format("%s-%s.pom", 
id.getArtifactId(), id.getVersion()));
 
-        try (FileOutputStream targetStream = new FileOutputStream(targetFile)) 
{
-            new MavenPomSupplierWriter(id).write(targetStream);
+        // If a POM already exists then there is not need to overwrite it as 
either the entire POM is lost
+        // or if its the a file previously generated here it must be the same
+        if(!targetFile.exists()) {
+            try (FileOutputStream targetStream = new 
FileOutputStream(targetFile)) {
+                new MavenPomSupplierWriter(id).write(targetStream);
 
 Review comment:
   I am maybe missing something - I just came back from PTO, so please 
apologise if I don't catch the fix immediately - but looks to me that the 
`targetFile` is written only if it does not exist...
   
   What I am not spotting correctly?
   
   TIA and thanks for the contribution! :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to