Skip to content

Commit c997ff3

Browse files
authored
Merge pull request #993 from pedro-hos/windows-keep-files-JBEAP-31797
[JBEAP-31797] jboss-eap-installation-manager under /bin does not update the jar files inside modules directory in windows.
2 parents 6f1a14f + 4e88323 commit c997ff3

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

prospero-common/src/main/java/org/wildfly/prospero/actions/ApplyCandidateAction.java

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
*/
1717
package org.wildfly.prospero.actions;
1818

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+
1931
import java.io.File;
2032
import java.io.IOException;
2133
import java.nio.file.AccessDeniedException;
@@ -29,6 +41,7 @@
2941
import java.util.ArrayList;
3042
import java.util.Arrays;
3143
import java.util.Collections;
44+
import java.util.Comparator;
3245
import java.util.HashMap;
3346
import java.util.List;
3447
import java.util.Locale;
@@ -39,9 +52,15 @@
3952

4053
import org.apache.commons.io.FileUtils;
4154
import org.eclipse.aether.artifact.Artifact;
42-
import org.jboss.galleon.Constants;
4355
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;
4564
import org.jboss.logging.Logger;
4665
import org.wildfly.prospero.ProsperoLogger;
4766
import org.wildfly.prospero.api.ArtifactChange;
@@ -52,25 +71,6 @@
5271
import org.wildfly.prospero.api.exceptions.InvalidUpdateCandidateException;
5372
import org.wildfly.prospero.api.exceptions.MetadataException;
5473
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;
7474
import org.wildfly.prospero.galleon.ArtifactCache;
7575
import org.wildfly.prospero.galleon.GalleonUtils;
7676
import org.wildfly.prospero.installation.git.GitStorage;
@@ -613,6 +613,10 @@ private List<FileConflict> compareServers(FsDiff fsDiff) throws IOException, Pro
613613
return Collections.unmodifiableList(conflicts);
614614
}
615615

616+
public void deleteWithStreams(Path path) throws IOException {
617+
Files.walk(path).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
618+
}
619+
616620
private List<FileConflict> doApplyUpdate(FsDiff fsDiff) throws IOException, ProvisioningException {
617621
List<FileConflict> conflicts = new ArrayList<>();
618622
// Handles user added/removed/modified files
@@ -693,7 +697,11 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
693697
if (ProsperoLogger.ROOT_LOGGER.isDebugEnabled()) {
694698
ProsperoLogger.ROOT_LOGGER.debug("Deleting the file " + relative + " that doesn't exist in the update");
695699
}
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+
}
697705
}
698706
return FileVisitResult.CONTINUE;
699707
}

0 commit comments

Comments
 (0)