bamaer commented on code in PR #9617:
URL: https://github.com/apache/hop/pull/9617#discussion_r4653056482
##########
plugins/misc/marketplace/src/main/java/org/apache/hop/marketplace/install/PluginUninstaller.java:
##########
@@ -49,9 +51,22 @@ public void uninstall(String artifactId) throws HopException
{
+ "'. Only plugins installed via the marketplace can be
uninstalled this way.");
}
- // Delete files deepest-first; leave shared lib/core jars (sticky, may be
used by others)
+ // Delete files deepest-first; leave shared lib/core jars (sticky, may be
used by others).
+ // Files of a previous version that an update could not remove yet go too,
unless another
+ // marketplace artifact has installed the same file since.
+ Set<String> paths = new
LinkedHashSet<>(PluginInstaller.nullSafe(receipt.getPaths()));
+ if (!PluginInstaller.nullSafe(receipt.getObsoletePaths()).isEmpty()) {
+ Set<String> otherReceiptPaths =
+ PluginInstaller.pathsOfOtherReceipts(hopHome, artifactId, log);
+ for (String obsolete : receipt.getObsoletePaths()) {
+ if (StringUtils.isNotBlank(obsolete)
+ &&
!otherReceiptPaths.contains(PluginInstaller.normalizeRelative(obsolete))) {
+ paths.add(obsolete);
Review Comment:
Thanks @hansva. A failed delete of an obsolete path is now logged and kept
in the receipt, along with the folders that hold it; the rest of the plugin is
still removed (7648c450b8).
##########
plugins/misc/marketplace/src/main/java/org/apache/hop/marketplace/install/PluginInstaller.java:
##########
@@ -295,19 +340,394 @@ public void activateAllPending() throws HopException {
if (staged.getFileName().toString().startsWith(".")) {
continue;
}
+ String artifactId = staged.getFileName().toString();
List<String> paths = collectRelativePaths(staged);
- activateStaged(staged.getFileName().toString(), paths);
+ // A receipt problem must not stop the other plugins from activating.
+ InstallReceipt receipt = null;
+ try {
+ receipt = readReceipt(hopHome, artifactId);
+ } catch (HopException e) {
+ log.logError(
+ "Could not read the install receipt of staged plugin "
+ + artifactId
+ + "; activating it without updating the receipt",
Review Comment:
Done: the unreadable receipt is moved aside to `<artifact>.json.unreadable`,
and a new receipt is written from the staged paths, with checksums but no
version (7648c450b8).
##########
plugins/misc/marketplace/src/main/java/org/apache/hop/marketplace/install/PluginInstaller.java:
##########
@@ -368,7 +875,16 @@ private void activateSharedCoreJar(String artifactId,
String relative, Path from
+ relative
+ " — leaving existing file. "
+ e.getMessage());
+ if (backup != null) {
+ try {
+ Files.deleteIfExists(backup);
+ } catch (IOException deleteError) {
+ log.logError("Could not remove unused backup " + backup,
deleteError);
Review Comment:
Done, the empty parents up to `BACKUP_DIR` are removed too (7648c450b8).
##########
plugins/misc/marketplace/src/main/java/org/apache/hop/marketplace/install/PluginInstaller.java:
##########
@@ -326,38 +773,98 @@ private void activateStaged(String artifactId,
List<String> relativePaths) throw
} catch (IOException e) {
throw new HopException("Failed to activate staged plugin " + artifactId,
e);
}
+ // Shared files an earlier version created or replaced and this one no
longer ships
+ for (Map.Entry<String, SharedFile> entry :
nullSafe(earlierInstalls).entrySet()) {
+ if (entry.getValue() != null
+ && entry.getValue().getAction() == SharedFileAction.NOT_SHIPPED
+ && !sharedFiles.containsKey(entry.getKey())) {
+ sharedFiles.put(entry.getKey(), entry.getValue());
+ }
+ }
+ return sharedFiles;
+ }
+
+ /**
+ * Where an install of {@code artifactId:version} backs up the shared file
it replaces: {@code
+ * <artifactId>/<version installed>/<installId>/<path>} under {@link
#BACKUP_DIR}.
+ */
+ static String backupPath(String artifactId, String version, String
installId, String relative) {
Review Comment:
Done: artifact id and version are reduced to one plain folder name, and the
backup path is checked to stay under `BACKUP_DIR` (7648c450b8).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]