mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[updater] dropping controversial directory pruning feature (IDEA-241455)
GitOrigin-RevId: d859e55ada3004a9601cfe7c5ab3f9fc0555b763
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5d15a0a7a6
commit
a130915d73
@@ -311,8 +311,6 @@ public class Patch {
|
||||
}
|
||||
|
||||
List<PatchAction> appliedActions = new ArrayList<>(actionsToApply.size());
|
||||
List<File> createdDirectories = new ArrayList<>();
|
||||
Set<File> createdOptionalFiles = new HashSet<>();
|
||||
|
||||
try {
|
||||
File _backupDir = backupDir;
|
||||
@@ -326,16 +324,6 @@ public class Patch {
|
||||
else {
|
||||
appliedActions.add(action);
|
||||
action.apply(patchFile, _backupDir, toDir);
|
||||
|
||||
if (action instanceof CreateAction) {
|
||||
File file = action.getFile(toDir);
|
||||
if (file.isDirectory()) {
|
||||
createdDirectories.add(0, file);
|
||||
}
|
||||
else if (action.isOptional()) {
|
||||
createdOptionalFiles.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -348,19 +336,6 @@ public class Patch {
|
||||
return new PatchFileCreator.ApplicationResult(false, appliedActions, t);
|
||||
}
|
||||
|
||||
for (File directory : createdDirectories) {
|
||||
File[] children = directory.listFiles();
|
||||
if (children != null && createdOptionalFiles.containsAll(Arrays.asList(children))) {
|
||||
Runner.logger().info("Pruning empty directory: " + directory);
|
||||
try {
|
||||
Utils.delete(directory);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Runner.logger().warn("pruning: " + directory, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// on macOS, we need to update bundle timestamp to reset Info.plist caches
|
||||
Files.setLastModifiedTime(toDir.toPath(), FileTime.from(Instant.now()));
|
||||
|
||||
@@ -532,41 +532,6 @@ public abstract class PatchApplyingRevertingTest extends PatchTestCase {
|
||||
assertAppliedAndReverted();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoNotLeaveEmptyDirectories() throws Exception {
|
||||
FileUtil.createDirectory(new File(myNewerDir, "new_empty_dir/sub_dir"));
|
||||
createPatch();
|
||||
|
||||
PatchFileCreator.PreparationResult preparationResult = PatchFileCreator.prepareAndValidate(myFile, myOlderDir, TEST_UI);
|
||||
assertAppliedAndReverted(preparationResult, expected -> {
|
||||
expected.remove("new_empty_dir/");
|
||||
expected.remove("new_empty_dir/sub_dir/");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatingMissingOptionalDirectory() throws Exception {
|
||||
FileUtil.copy(new File(myOlderDir, "bin/idea.bat"), new File(myOlderDir, "jre/bin/java"));
|
||||
FileUtil.copy(new File(myOlderDir, "lib/annotations.jar"), new File(myOlderDir, "jre/lib/rt.jar"));
|
||||
FileUtil.copy(new File(myOlderDir, "lib/boot.jar"), new File(myOlderDir, "jre/lib/tools.jar"));
|
||||
resetNewerDir();
|
||||
FileUtil.rename(new File(myNewerDir, "jre"), new File(myNewerDir, "jre32"));
|
||||
FileUtil.writeToFile(new File(myNewerDir, "jre32/lib/font-config.bfc"), "# empty");
|
||||
|
||||
myPatchSpec.setOptionalFiles(Arrays.asList(
|
||||
"jre/bin/java", "jre/bin/jvm.dll", "jre/lib/rt.jar", "jre/lib/tools.jar",
|
||||
"jre32/bin/java", "jre32/bin/jvm.dll", "jre32/lib/rt.jar", "jre32/lib/tools.jar", "jre32/lib/font-config.bfc"));
|
||||
createPatch();
|
||||
|
||||
FileUtil.delete(new File(myOlderDir, "jre"));
|
||||
|
||||
PatchFileCreator.PreparationResult preparationResult = PatchFileCreator.prepareAndValidate(myFile, myOlderDir, TEST_UI);
|
||||
assertAppliedAndReverted(preparationResult, expected -> {
|
||||
List<String> keys = ContainerUtil.findAll(expected.keySet(), k -> k.startsWith("jre32/"));
|
||||
keys.forEach(expected::remove);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadOnlyFilesAreDeletable() throws Exception {
|
||||
File file = new File(myOlderDir, "bin/read_only_to_delete");
|
||||
|
||||
Reference in New Issue
Block a user