-
Type:
Suggestion
-
Resolution: Fixed
-
Priority:
High
-
Affects Version/s: None
-
Component/s: Trac
JIRA Trac import currently can't handle attachments in Trac 1.0 (soon to be released):
2012-08-13 13:18:55,312 ERROR - Failed to get attachment com.atlassian.jira.exception.DataAccessException: Attachment doesn't exist: attachments/ticket/3354/ticket.pdf at com.atlassian.jira.plugins.importer.imports.trac.transformer.AttachmentTransformer.copyAttachment(AttachmentTransformer.java:102) at com.atlassian.jira.plugins.importer.imports.trac.transformer.AttachmentTransformer.transform(AttachmentTransformer.java:71) at com.atlassian.jira.plugins.importer.imports.trac.transformer.AttachmentTransformer.transform(AttachmentTransformer.java:28) at com.atlassian.jira.plugins.importer.web.JdbcConnection.queryDb(JdbcConnection.java:164) at com.atlassian.jira.plugins.importer.web.JdbcConnection.queryDb(JdbcConnection.java:146) at com.atlassian.jira.plugins.importer.imports.trac.TracDataBean.getAttachmentsForIssue(TracDataBean.java:102) at com.atlassian.jira.plugins.importer.imports.importer.impl.DefaultJiraDataImporter.createIssue(DefaultJiraDataImporter.java:861) at com.atlassian.jira.plugins.importer.imports.importer.impl.DefaultJiraDataImporter.importIssues(DefaultJiraDataImporter.java:716) at com.atlassian.jira.plugins.importer.imports.importer.impl.DefaultJiraDataImporter.doImport(DefaultJiraDataImporter.java:305) at com.atlassian.jira.plugins.importer.imports.importer.impl.ImporterCallable.call(ImporterCallable.java:25) at com.atlassian.jira.plugins.importer.imports.importer.impl.ImporterCallable.call(ImporterCallable.java:14) at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:359) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at com.atlassian.multitenant.impl.DefaultMultiTenantManager.runForTenant(DefaultMultiTenantManager.java:61) at com.atlassian.multitenant.juc.MultiTenantExecutors$WrappedRunnable.run(MultiTenantExecutors.java:160) at com.atlassian.jira.task.ForkedThreadExecutor$ForkedRunnableDecorator.run(ForkedThreadExecutor.java:249) at java.lang.Thread.run(Unknown Source)
Attachments are saved using SHA1 hash, instead of their real name now. (http://trac.edgewall.org/changeset/11028 is the commit in trac to introduce this change.)
The new format for persisted files on disk is something like this:
files/attachments/ticket/a09/a09f29cc98d27721cdf284e6d5cfd0b93c146491/c437fa23bfbb61a2c7625dd7413e10bdd27eddb0.png
Where "ticket" is type column in trac attachment table, a09f29cc98d27721cdf284e6d5cfd0b93c146491 is the sha1 hash of the string in id column in trac attachment table, and c437fa23bfbb61a2c7625dd7413e10bdd27eddb0 is the sha1 hash of filename column in trac attachment table. The file name on disk should ends with the same extension as the filename column in the table (If there is an extension in the original filename.)
In order to tell whether the files are in sha1 hash (trac 1.0 and later), or their original name (< trac 1.0), check for existence of the attachments directory in the root of the zip archive, if it does not exist, then this is a trac 1.0 zip file. (Attachments are under files/attachments.)