Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle bundle folders in VirtualArtifactRepository.transferArtifact #1008

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.pde.internal.core.target;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -22,9 +23,11 @@
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipOutputStream;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -34,6 +37,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.metadata.expression.QueryResult;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
Expand Down Expand Up @@ -123,8 +127,17 @@ private void transferArtifact(Object artifactModel, OutputStream destination) th
if (location == null) {
throw new FileNotFoundException(bundleInfo.getSymbolicName());
}
try (InputStream is = location.toURL().openStream()) {
is.transferTo(destination);

File bundleLocation = new File(location);
if (bundleLocation.isFile()) {
try (InputStream is = new FileInputStream(bundleLocation)) {
is.transferTo(destination);
}
Comment on lines +133 to +135
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try (InputStream is = new FileInputStream(bundleLocation)) {
is.transferTo(destination);
}
Files.copy(bundleLocation.toPath(), destination);

} else {
ZipOutputStream zip = new ZipOutputStream(destination);
FileUtils.zip(zip, bundleLocation, Set.of(), FileUtils.createRootPathComputer(bundleLocation));
zip.finish();
zip.flush();
laeubi marked this conversation as resolved.
Show resolved Hide resolved
}
} else if (artifactModel instanceof IFeatureModel featureModel) {
String installLocation = featureModel.getInstallLocation();
Expand Down
Loading