mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Updater: patches for symbolic link fixed. Added more information in updater log file.
This commit is contained in:
@@ -73,6 +73,7 @@ public class CreateAction extends PatchAction {
|
||||
|
||||
@Override
|
||||
protected void doApply(ZipFile patchFile, File backupDir, File toFile) throws IOException {
|
||||
Runner.logger().info("Create action. File: " + toFile.getAbsolutePath());
|
||||
prepareToWriteFile(toFile);
|
||||
|
||||
ZipEntry entry = Utils.getZipEntry(patchFile, myPath);
|
||||
|
||||
@@ -59,9 +59,11 @@ public class DeleteAction extends PatchAction {
|
||||
|
||||
@Override
|
||||
protected void doApply(ZipFile patchFile, File backupDir, File toFile) throws IOException {
|
||||
Runner.logger().info("Delete action. File: " + toFile.getAbsolutePath());
|
||||
//NOTE: a folder can be deleted only in case if it does not contain any user's files/folders.
|
||||
File[] listFiles = toFile.listFiles();
|
||||
if (!toFile.isDirectory() || (listFiles != null && listFiles.length == 0)) {
|
||||
Runner.logger().info("Delete: " + toFile.getAbsolutePath());
|
||||
Utils.delete(toFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,10 @@ public class DiffCalculator {
|
||||
// Find first by content
|
||||
for (Map.Entry<String, Long> create : toCreate.entrySet()) {
|
||||
boolean isDir = create.getKey().endsWith("/");
|
||||
boolean isLink = create.getKey().endsWith(".dylib");
|
||||
String source = byContent.get(create.getValue());
|
||||
boolean found = false;
|
||||
if (source != null && !isDir) {
|
||||
if (source != null && !isDir && !isLink) {
|
||||
// Found a file with the same content use it, unless it's critical
|
||||
if (!critical.contains(source)) {
|
||||
result.filesToUpdate.put(create.getKey(), new Update(source, result.filesToDelete.get(source), true));
|
||||
@@ -54,7 +55,7 @@ public class DiffCalculator {
|
||||
else {
|
||||
File fileToCreate = new File(create.getKey());
|
||||
List<String> sameName = byName.get(fileToCreate.getName());
|
||||
if (sameName != null && !isDir) {
|
||||
if (sameName != null && !isDir && !isLink) {
|
||||
String best = findBestCandidateForMove(sameName, create.getKey());
|
||||
// Found a file with the same name, if it's not critical use it, worst case as big as a create.
|
||||
if (!critical.contains(best)) {
|
||||
|
||||
@@ -50,6 +50,7 @@ public class UpdateAction extends BaseUpdateAction {
|
||||
@Override
|
||||
protected void doApply(ZipFile patchFile, File backupDir, File toFile) throws IOException {
|
||||
File source = getSource(backupDir);
|
||||
Runner.logger().info("Update action. File: " + toFile.getAbsolutePath());
|
||||
File updated;
|
||||
if (!myIsMove) {
|
||||
updated = Utils.createTempFile();
|
||||
|
||||
@@ -117,17 +117,19 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void copy(File from, File to) throws IOException {
|
||||
Runner.logger().info("from " + from.getPath() + " to " + to.getPath());
|
||||
if (from.isDirectory()) {
|
||||
to.mkdirs();
|
||||
File[] files = from.listFiles();
|
||||
if (files == null) throw new IOException("Cannot get directory's content: " + from);
|
||||
for (File each : files) {
|
||||
copy(each, new File(to, each.getName()));
|
||||
if (! to.exists()) {
|
||||
Runner.logger().info("Dir: " + from.getPath() + " to " + to.getPath());
|
||||
to.mkdirs();
|
||||
File[] files = from.listFiles();
|
||||
if (files == null) throw new IOException("Cannot get directory's content: " + from);
|
||||
for (File each : files) {
|
||||
copy(each, new File(to, each.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (! isLink(from)) {
|
||||
} else {
|
||||
if (! isLink(from) && from.exists()) {
|
||||
Runner.logger().info("File: " + from.getPath() + " to " + to.getPath());
|
||||
InputStream in = new BufferedInputStream(new FileInputStream(from));
|
||||
try {
|
||||
copyStreamToFile(in, to);
|
||||
|
||||
Reference in New Issue
Block a user