|
16 | 16 | */ |
17 | 17 | package org.wildfly.prospero.actions; |
18 | 18 |
|
| 19 | +import static org.jboss.galleon.diff.FsDiff.ADDED; |
| 20 | +import static org.jboss.galleon.diff.FsDiff.CONFLICT; |
| 21 | +import static org.jboss.galleon.diff.FsDiff.CONFLICTS_WITH_THE_UPDATED_VERSION; |
| 22 | +import static org.jboss.galleon.diff.FsDiff.FORCED; |
| 23 | +import static org.jboss.galleon.diff.FsDiff.HAS_BEEN_REMOVED_FROM_THE_UPDATED_VERSION; |
| 24 | +import static org.jboss.galleon.diff.FsDiff.HAS_CHANGED_IN_THE_UPDATED_VERSION; |
| 25 | +import static org.jboss.galleon.diff.FsDiff.MODIFIED; |
| 26 | +import static org.jboss.galleon.diff.FsDiff.REMOVED; |
| 27 | +import static org.jboss.galleon.diff.FsDiff.formatMessage; |
| 28 | +import static org.wildfly.prospero.metadata.ProsperoMetadataUtils.CURRENT_VERSION_FILE; |
| 29 | +import static org.wildfly.prospero.metadata.ProsperoMetadataUtils.METADATA_DIR; |
| 30 | + |
19 | 31 | import java.io.File; |
20 | 32 | import java.io.IOException; |
21 | 33 | import java.nio.file.AccessDeniedException; |
|
29 | 41 | import java.util.ArrayList; |
30 | 42 | import java.util.Arrays; |
31 | 43 | import java.util.Collections; |
| 44 | +import java.util.Comparator; |
32 | 45 | import java.util.HashMap; |
33 | 46 | import java.util.List; |
34 | 47 | import java.util.Locale; |
|
39 | 52 |
|
40 | 53 | import org.apache.commons.io.FileUtils; |
41 | 54 | import org.eclipse.aether.artifact.Artifact; |
42 | | -import org.jboss.galleon.Constants; |
43 | 55 | import org.jboss.galleon.BaseErrors; |
44 | | - |
| 56 | +import org.jboss.galleon.Constants; |
| 57 | +import org.jboss.galleon.ProvisioningException; |
| 58 | +import org.jboss.galleon.diff.FsDiff; |
| 59 | +import org.jboss.galleon.diff.FsEntry; |
| 60 | +import org.jboss.galleon.layout.SystemPaths; |
| 61 | +import org.jboss.galleon.util.HashUtils; |
| 62 | +import org.jboss.galleon.util.IoUtils; |
| 63 | +import org.jboss.galleon.util.PathsUtils; |
45 | 64 | import org.jboss.logging.Logger; |
46 | 65 | import org.wildfly.prospero.ProsperoLogger; |
47 | 66 | import org.wildfly.prospero.api.ArtifactChange; |
|
52 | 71 | import org.wildfly.prospero.api.exceptions.InvalidUpdateCandidateException; |
53 | 72 | import org.wildfly.prospero.api.exceptions.MetadataException; |
54 | 73 | import org.wildfly.prospero.api.exceptions.OperationException; |
55 | | -import org.jboss.galleon.ProvisioningException; |
56 | | -import org.jboss.galleon.diff.FsDiff; |
57 | | -import static org.jboss.galleon.diff.FsDiff.ADDED; |
58 | | -import static org.jboss.galleon.diff.FsDiff.CONFLICT; |
59 | | -import static org.jboss.galleon.diff.FsDiff.CONFLICTS_WITH_THE_UPDATED_VERSION; |
60 | | -import static org.jboss.galleon.diff.FsDiff.FORCED; |
61 | | -import static org.jboss.galleon.diff.FsDiff.HAS_BEEN_REMOVED_FROM_THE_UPDATED_VERSION; |
62 | | -import static org.jboss.galleon.diff.FsDiff.HAS_CHANGED_IN_THE_UPDATED_VERSION; |
63 | | -import static org.jboss.galleon.diff.FsDiff.MODIFIED; |
64 | | -import static org.jboss.galleon.diff.FsDiff.REMOVED; |
65 | | -import static org.jboss.galleon.diff.FsDiff.formatMessage; |
66 | | -import static org.wildfly.prospero.metadata.ProsperoMetadataUtils.CURRENT_VERSION_FILE; |
67 | | -import static org.wildfly.prospero.metadata.ProsperoMetadataUtils.METADATA_DIR; |
68 | | - |
69 | | -import org.jboss.galleon.diff.FsEntry; |
70 | | -import org.jboss.galleon.layout.SystemPaths; |
71 | | -import org.jboss.galleon.util.HashUtils; |
72 | | -import org.jboss.galleon.util.IoUtils; |
73 | | -import org.jboss.galleon.util.PathsUtils; |
74 | 74 | import org.wildfly.prospero.galleon.ArtifactCache; |
75 | 75 | import org.wildfly.prospero.galleon.GalleonUtils; |
76 | 76 | import org.wildfly.prospero.installation.git.GitStorage; |
@@ -613,6 +613,10 @@ private List<FileConflict> compareServers(FsDiff fsDiff) throws IOException, Pro |
613 | 613 | return Collections.unmodifiableList(conflicts); |
614 | 614 | } |
615 | 615 |
|
| 616 | + public void deleteWithStreams(Path path) throws IOException { |
| 617 | + Files.walk(path).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); |
| 618 | + } |
| 619 | + |
616 | 620 | private List<FileConflict> doApplyUpdate(FsDiff fsDiff) throws IOException, ProvisioningException { |
617 | 621 | List<FileConflict> conflicts = new ArrayList<>(); |
618 | 622 | // Handles user added/removed/modified files |
@@ -693,7 +697,11 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) |
693 | 697 | if (ProsperoLogger.ROOT_LOGGER.isDebugEnabled()) { |
694 | 698 | ProsperoLogger.ROOT_LOGGER.debug("Deleting the file " + relative + " that doesn't exist in the update"); |
695 | 699 | } |
696 | | - IoUtils.recursiveDelete(file); |
| 700 | + try { |
| 701 | + deleteWithStreams(file); |
| 702 | + } catch (Exception e2) { |
| 703 | + ProsperoLogger.ROOT_LOGGER.debug("Problem during delete the file: " + relative + " with: " + e2.getMessage()); |
| 704 | + } |
697 | 705 | } |
698 | 706 | return FileVisitResult.CONTINUE; |
699 | 707 | } |
|
0 commit comments