Moving pages or page trees results in broken attachments
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
We've fixed this issue in Confluence 8.1 and later versions by introducing a more robust way of storing attachments that will prevent broken or missing attachments during page moves. Learn more about the attachment directory
要約
After moving pages or page tree, attachment become broken on moved pages.
環境
Confluence installed on Windows OS
診断
The following errors can be seen in atlassian-confluence.log
ERROR [Long running task: Move Page] [atlassian.confluence.event.ConfluenceEventDispatcher] run There was an exception thrown trying to dispatch event [com.atlassian.confluence.event.events.content.page.PageMoveEvent@6271dc2f[theMover=ConfluenceUserImpl...{details of content being moved}
...
com.atlassian.confluence.event.events.content.page.PageMoveEvent), listener=com.atlassian.confluence.pages.persistence.dao.filesystem.UpdateAttachmentsOnFilesystemOnPageMoveListener@123456} (timed)]
-- referer: http://confluence:8090/display/SPACEKEY/PAGE_NAME | url: /pages/movepage.action | traceId: 1a2s3d4f5g6h | userName: username | action: movepage
java.lang.RuntimeException: Failed to move the attachment data. Listener: com.atlassian.confluence.pages.persistence.dao.filesystem.UpdateAttachmentsOnFilesystemOnPageMoveListener event: com.atlassian.confluence.event.events.content.page.PageMoveEvent
...
Caused by: com.atlassian.confluence.pages.persistence.dao.filesystem.UpdateAttachmentsOnFileSystemException: Failed to move the attachment data
...
Caused by: com.atlassian.confluence.pages.persistence.dao.filesystem.AttachmentDataFileSystemException: Could not move the attachment data along with the page for move of page [Page Title]
...
Caused by: java.io.IOException: Unable to delete file: c:/path/to/file
at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2400)
at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1721)
原因
Windows has detailed permissions control and Delete Permission can be explicitly disabled.
If that happens, account used to run Confluence will fail to move the attachments stored in file system, as moving operation would require for the physical file to be removed from its old location.
ソリューション
Make sure Confluence service is running with a dedicated account and that account has Full Permissions to it's home directory as per Creating a Dedicated User Account on the Operating System to Run Confluence
As all attachments would still exist in Attachment folder within their appropriate content ID directories, you can use python script from How to resolve missing attachments in Confluence KB to manually move them under new location within file system hierarchy