From 0af5a819d92981b42c6baba9324173c931bcf02d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 5 Jun 2012 21:43:53 +0000 Subject: [PATCH] when deleting an artifact md5 and sha1 must be deleted too git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1346611 13f79535-47bb-0310-9956-ffa450edef68 --- .../content/ManagedDefaultRepositoryContent.java | 14 ++++++++++++++ .../rest/services/RepositoriesServiceTest.java | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java index aabda49cf..0c626436f 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/ManagedDefaultRepositoryContent.java @@ -86,6 +86,20 @@ public class ManagedDefaultRepositoryContent { FileUtils.deleteQuietly( filePath ); } + + File filePathmd5 = new File( getRepoRoot(), path + ".md5" ); + + if ( filePathmd5.exists() ) + { + FileUtils.deleteQuietly( filePathmd5 ); + } + + File filePathsha1 = new File( getRepoRoot(), path + ".sha1" ); + + if ( filePathsha1.exists() ) + { + FileUtils.deleteQuietly( filePathsha1 ); + } } public String getId() diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java index 59fcbbd65..ad492a6c7 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java @@ -213,8 +213,17 @@ public class RepositoriesServiceTest File artifactFile = new File( "target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar" ); + File artifactFilemd5 = new File( + "target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.md5" ); + + File artifactFilesha1 = new File( + "target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar.sha1" ); + assertTrue( "artifact not exists:" + artifactFile.getPath(), artifactFile.exists() ); + assertTrue( "md5 not exists:" + artifactFilemd5.getPath(), artifactFilemd5.exists() ); + assertTrue( "sha1 not exists:" + artifactFilesha1.getPath(), artifactFilesha1.exists() ); + Artifact artifact = new Artifact(); artifact.setGroupId( "commons-logging" ); artifact.setArtifactId( "commons-logging" ); @@ -228,6 +237,8 @@ public class RepositoriesServiceTest repositoriesService.deleteArtifact( artifact ); assertFalse( "artifact not deleted exists:" + artifactFile.getPath(), artifactFile.exists() ); + assertFalse( "md5 still exists:" + artifactFilemd5.getPath(), artifactFilemd5.exists() ); + assertFalse( "sha1 still exists:" + artifactFilesha1.getPath(), artifactFilesha1.exists() ); artifacts = browseService.getArtifactDownloadInfos( "commons-logging", "commons-logging", "1.0.1", SOURCE_REPO_ID ); -- 2.39.5