]> source.dussan.org Git - archiva.git/commitdiff
check if metadata exists first before updating and copying to target repo
authorMaria Odea B. Ching <oching@apache.org>
Fri, 15 Oct 2010 05:15:51 +0000 (05:15 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Fri, 15 Oct 2010 05:15:51 +0000 (05:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1022822 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java

index 7b45b067dc1697b2865ffb641f8afa55a1bd348f..294956a64623c17234685e80183576436e6d6d6d 100644 (file)
@@ -187,37 +187,44 @@ public class Maven2RepositoryMerger
                 pathTranslator.toFile( new File( sourceRepoPath ), artifactMetadata.getNamespace(),
                                        artifactMetadata.getProject(), artifactMetadata.getVersion(),
                                        METADATA_FILENAME );
-            String relativePathToVersionMetadataFile =
-                versionMetaDataFileInSourceRepo.getAbsolutePath().split( sourceRepoPath )[1];
-            File versionMetaDataFileInTargetRepo = new File( targetRepoPath, relativePathToVersionMetadataFile );
 
-            if ( !versionMetaDataFileInTargetRepo.exists() )
+            if( versionMetaDataFileInSourceRepo.exists() )
             {
-                copyFile( versionMetaDataFileInSourceRepo, versionMetaDataFileInTargetRepo );
-            }
-            else
-            {
-                updateVersionMetadata( versionMetaDataFileInTargetRepo, artifactMetadata, lastUpdatedTimestamp );
+                String relativePathToVersionMetadataFile =
+                    versionMetaDataFileInSourceRepo.getAbsolutePath().split( sourceRepoPath )[1];
+                File versionMetaDataFileInTargetRepo = new File( targetRepoPath, relativePathToVersionMetadataFile );
+
+                if ( !versionMetaDataFileInTargetRepo.exists() )
+                {
+                    copyFile( versionMetaDataFileInSourceRepo, versionMetaDataFileInTargetRepo );
+                }
+                else
+                {
+                    updateVersionMetadata( versionMetaDataFileInTargetRepo, artifactMetadata, lastUpdatedTimestamp );
 
+                }
             }
 
             // updating project meta data file
             String projectDirectoryInSourceRepo = new File( versionMetaDataFileInSourceRepo.getParent() ).getParent();
             File projectMetadataFileInSourceRepo = new File( projectDirectoryInSourceRepo, METADATA_FILENAME );
 
-            String relativePathToProjectMetadataFile =
-                projectMetadataFileInSourceRepo.getAbsolutePath().split( sourceRepoPath )[1];
-            File projectMetadataFileInTargetRepo = new File( targetRepoPath, relativePathToProjectMetadataFile );
-
-            if ( !projectMetadataFileInTargetRepo.exists() )
+            if( projectMetadataFileInSourceRepo.exists() )
             {
+                String relativePathToProjectMetadataFile =
+                    projectMetadataFileInSourceRepo.getAbsolutePath().split( sourceRepoPath )[1];
+                File projectMetadataFileInTargetRepo = new File( targetRepoPath, relativePathToProjectMetadataFile );
 
-                copyFile( versionMetaDataFileInSourceRepo, projectMetadataFileInSourceRepo );
-            }
-            else
-            {
-                updateProjectMetadata( projectMetadataFileInTargetRepo, artifactMetadata, lastUpdatedTimestamp,
-                                       timestamp );
+                if ( !projectMetadataFileInTargetRepo.exists() )
+                {
+
+                    copyFile( projectMetadataFileInSourceRepo, projectMetadataFileInSourceRepo );
+                }
+                else
+                {
+                    updateProjectMetadata( projectMetadataFileInTargetRepo, artifactMetadata, lastUpdatedTimestamp,
+                                           timestamp );
+                }
             }
         }