{"action":"created","issue":{"url":"https://api.github.com/repos/Connexions/cnx-publishing/issues/94","labels_url":"https://api.github.com/repos/Connexions/cnx-publishing/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/Connexions/cnx-publishing/issues/94/comments","events_url":"https://api.github.com/repos/Connexions/cnx-publishing/issues/94/events","html_url":"https://github.com/Connexions/cnx-publishing/issues/94","id":63731568,"number":94,"title":"Duplication resource used in the same document errors","user":{"login":"pumazi","id":168470,"avatar_url":"https://avatars.githubusercontent.com/u/168470?v=3","gravatar_id":"","url":"https://api.github.com/users/pumazi","html_url":"https://github.com/pumazi","followers_url":"https://api.github.com/users/pumazi/followers","following_url":"https://api.github.com/users/pumazi/following{/other_user}","gists_url":"https://api.github.com/users/pumazi/gists{/gist_id}","starred_url":"https://api.github.com/users/pumazi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pumazi/subscriptions","organizations_url":"https://api.github.com/users/pumazi/orgs","repos_url":"https://api.github.com/users/pumazi/repos","events_url":"https://api.github.com/users/pumazi/events{/privacy}","received_events_url":"https://api.github.com/users/pumazi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Connexions/cnx-publishing/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-23T14:08:38Z","updated_at":"2015-03-23T21:36:14Z","closed_at":null,"body":"Because we are using the data uri scheme for resources, the normalization of resources within the cnx-epub logic is bypassed. As a result a data integrity error is raised from the database.\r\n\r\n```pytb\r\nTraceback (most recent call last):\r\n  ...\r\n  File \"/opt/dev/cnx-publishing/cnxpublishing/views.py\", line 68, in publish\r\n    state, messages = poke_publication_state(publication_id)\r\n  File \"/opt/dev/cnx-publishing/cnxpublishing/db.py\", line 97, in wrapped\r\n    return func(*args, **kwargs)\r\n  File \"/opt/dev/cnx-publishing/cnxpublishing/db.py\", line 866, in poke_publication_state\r\n    publication_state = publish_pending(cursor, publication_id)\r\n  File \"/opt/dev/cnx-publishing/cnxpublishing/db.py\", line 978, in publish_pending\r\n    ident_hash = publish_model(cursor, document, publisher, message)\r\n  File \"/opt/dev/cnx-publishing/cnxpublishing/publish.py\", line 287, in publish_model\r\n    _insert_resource_file(cursor, module_ident, resource)\r\n  File \"/opt/dev/cnx-publishing/cnxpublishing/publish.py\", line 221, in _insert_resource_file\r\n    VALUES (%s, %s, %s, %s)\"\"\", args)\r\nIntegrityError: duplicate key value violates unique constraint \"module_files_idx\"\r\nDETAIL:  Key (module_ident, filename)=(119140, 9631bb0341681c6f5281bab2cbd8b1f8b53f477e) already exists.\r\n```\r\n\r\nReproducible by including the same image (in data-uri format) twice within a document."},"comment":{"url":"https://api.github.com/repos/Connexions/cnx-publishing/issues/comments/85207266","html_url":"https://github.com/Connexions/cnx-publishing/issues/94#issuecomment-85207266","issue_url":"https://api.github.com/repos/Connexions/cnx-publishing/issues/94","id":85207266,"user":{"login":"reedstrm","id":253212,"avatar_url":"https://avatars.githubusercontent.com/u/253212?v=3","gravatar_id":"","url":"https://api.github.com/users/reedstrm","html_url":"https://github.com/reedstrm","followers_url":"https://api.github.com/users/reedstrm/followers","following_url":"https://api.github.com/users/reedstrm/following{/other_user}","gists_url":"https://api.github.com/users/reedstrm/gists{/gist_id}","starred_url":"https://api.github.com/users/reedstrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reedstrm/subscriptions","organizations_url":"https://api.github.com/users/reedstrm/orgs","repos_url":"https://api.github.com/users/reedstrm/repos","events_url":"https://api.github.com/users/reedstrm/events{/privacy}","received_events_url":"https://api.github.com/users/reedstrm/received_events","type":"User","site_admin":false},"created_at":"2015-03-23T21:36:14Z","updated_at":"2015-03-23T21:36:14Z","body":"If those filenames are sha1 hashes, then the file is identical, so we can just skip storing it."}}