static PatchingTask createModuleTask(final PatchingTaskDescription description, boolean rollback) { if (rollback) { return new ModuleRollbackTask(description); } else { final ModificationType type = description.getModificationType(); if(type == ModificationType.REMOVE) { return new ModuleRemoveTask(description); } else { return new ModuleUpdateTask(description); } } }
@Override ContentModification createRollbackEntry(ContentModification original, byte[] targetHash, byte[] itemHash) { // Although modules are ignored for rollback, we still keep track of our changes final ModuleItem item = createContentItem(contentItem, itemHash); final ModificationType type; // Check if the module did not exist before. Invalidated patches might include the module already // and we need to track that they can be rolled back to the last state if (original.getType() != ModificationType.MODIFY && itemHash.length == 0) { type = ModificationType.REMOVE; } else { type = ModificationType.MODIFY; } return new ContentModification(item, targetHash, type, original.getCondition()); }
@Override public boolean prepare(final PatchingTaskContext context) throws IOException { // Backup backupHash = backup(context); // If the content is already present just resolve any conflict automatically final byte[] contentHash = contentItem.getContentHash(); if(Arrays.equals(backupHash, contentHash)) { return true; } // See if the content matches our expected target final byte[] expected = description.getModification().getTargetHash(); if(Arrays.equals(backupHash, expected)) { // Don't resolve conflicts from the history return ! description.hasConflicts(); } // System.out.println("ModuleUpdateTask.prepare " + description.getModificationType() + " backup " + (backupHash == IoUtils.NO_CONTENT)); // the problem here appears for compact CPs when a module at some point was added then removed and then re-added // re-adding will be MODIFY because the removed module will exist on the FS but will be marked as absent in its module.xml // so applying re-add (MODIFY) to the version where the module didn't exist will fail return false; }
@Override public boolean prepare(final PatchingTaskContext context) throws IOException { // Backup backupHash = backup(context); // If the content is already present just resolve any conflict automatically final byte[] contentHash = contentItem.getContentHash(); if(Arrays.equals(backupHash, contentHash)) { return true; } // See if the content matches our expected target final byte[] expected = description.getModification().getTargetHash(); if(Arrays.equals(backupHash, expected)) { // Don't resolve conflicts from the history return ! description.hasConflicts(); } // System.out.println("ModuleUpdateTask.prepare " + description.getModificationType() + " backup " + (backupHash == IoUtils.NO_CONTENT)); // the problem here appears for compact CPs when a module at some point was added then removed and then re-added // re-adding will be MODIFY because the removed module will exist on the FS but will be marked as absent in its module.xml // so applying re-add (MODIFY) to the version where the module didn't exist will fail return false; }
static PatchingTask createModuleTask(final PatchingTaskDescription description, boolean rollback) { if (rollback) { return new ModuleRollbackTask(description); } else { final ModificationType type = description.getModificationType(); if(type == ModificationType.REMOVE) { return new ModuleRemoveTask(description); } else { return new ModuleUpdateTask(description); } } }
@Override ContentModification createRollbackEntry(ContentModification original, byte[] targetHash, byte[] itemHash) { // Although modules are ignored for rollback, we still keep track of our changes final ModuleItem item = createContentItem(contentItem, itemHash); final ModificationType type; // Check if the module did not exist before. Invalidated patches might include the module already // and we need to track that they can be rolled back to the last state if (original.getType() != ModificationType.MODIFY && itemHash.length == 0) { type = ModificationType.REMOVE; } else { type = ModificationType.MODIFY; } return new ContentModification(item, targetHash, type, original.getCondition()); }