diff --git a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-attachments/src/main/java/org/xwiki/store/legacy/store/internal/AttachmentArchiveSaveRunnable.java b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-attachments/src/main/java/org/xwiki/store/legacy/store/internal/AttachmentArchiveSaveRunnable.java index 03952da..bc03402 100644 --- a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-attachments/src/main/java/org/xwiki/store/legacy/store/internal/AttachmentArchiveSaveRunnable.java +++ b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-attachments/src/main/java/org/xwiki/store/legacy/store/internal/AttachmentArchiveSaveRunnable.java @@ -23,12 +23,7 @@ import java.util.ArrayList; import java.util.List; -import com.xpn.xwiki.doc.XWikiAttachment; -import com.xpn.xwiki.doc.XWikiAttachmentArchive; -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.store.VoidAttachmentVersioningStore; - +import org.apache.commons.lang3.StringUtils; import org.suigeneris.jrcs.rcs.Version; import org.xwiki.store.FileSaveTransactionRunnable; import org.xwiki.store.StartableTransactionRunnable; @@ -38,6 +33,12 @@ import org.xwiki.store.serialization.SerializationStreamProvider; import org.xwiki.store.serialization.Serializer; +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.XWikiException; +import com.xpn.xwiki.doc.XWikiAttachment; +import com.xpn.xwiki.doc.XWikiAttachmentArchive; +import com.xpn.xwiki.store.VoidAttachmentVersioningStore; + /** * A TransactionRunnable for saving attachment archives. * It uses a chain of FileSaveTransactionRunnable so the attachment will either be saved or fail @@ -82,8 +83,10 @@ public AttachmentArchiveSaveRunnable(final XWikiAttachmentArchive archive, // Add the content files which need updating and add the attachments to the list. for (int i = 0; i < versions.length; i++) { final String versionName = versions[i].toString(); - final XWikiAttachment attachVer = - archive.getRevision(archive.getAttachment(), versionName, context); + XWikiAttachment attachVer = archive.getAttachment(); + if (attachVer == null || !StringUtils.equals(versionName, attachVer.getVersion())) { + attachVer = archive.getRevision(attachVer, versionName, context); + } attachmentVersions.add(attachVer); // If the content is not dirty and the file was already saved then we will not update.