{"action":"created","issue":{"url":"https://api.github.com/repos/Coursemology/coursemology2/issues/880","repository_url":"https://api.github.com/repos/Coursemology/coursemology2","labels_url":"https://api.github.com/repos/Coursemology/coursemology2/issues/880/labels{/name}","comments_url":"https://api.github.com/repos/Coursemology/coursemology2/issues/880/comments","events_url":"https://api.github.com/repos/Coursemology/coursemology2/issues/880/events","html_url":"https://github.com/Coursemology/coursemology2/pull/880","id":137309051,"number":880,"title":"Making attachments immutable (Files are not duplicated any more)","user":{"login":"allenwq","id":4983239,"avatar_url":"https://avatars.githubusercontent.com/u/4983239?v=3","gravatar_id":"","url":"https://api.github.com/users/allenwq","html_url":"https://github.com/allenwq","followers_url":"https://api.github.com/users/allenwq/followers","following_url":"https://api.github.com/users/allenwq/following{/other_user}","gists_url":"https://api.github.com/users/allenwq/gists{/gist_id}","starred_url":"https://api.github.com/users/allenwq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenwq/subscriptions","organizations_url":"https://api.github.com/users/allenwq/orgs","repos_url":"https://api.github.com/users/allenwq/repos","events_url":"https://api.github.com/users/allenwq/events{/privacy}","received_events_url":"https://api.github.com/users/allenwq/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-02-29T16:57:24Z","updated_at":"2016-03-09T02:10:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Coursemology/coursemology2/pulls/880","html_url":"https://github.com/Coursemology/coursemology2/pull/880","diff_url":"https://github.com/Coursemology/coursemology2/pull/880.diff","patch_url":"https://github.com/Coursemology/coursemology2/pull/880.patch"},"body":"This implements #779\r\n\r\n- A new `AttachableAttachment` model is added, it servers as the counter between `Attachment` and `attachable`.\r\n-  The SHA256 hash of the file will be calculated before actually storing it (or uploading to S3), if there is an existing attachment with the same hash, the file will be directly linked to that attachment.\r\n- The hash stores in the name of the attachment model, and there is a unique index on name.\r\n- `attachment=` is replaced with `attachable_attachment=`, we should not directly manipulates attachments anymore.\r\n\r\n@lowjoel You might want to review this commit by commit\r\n"},"comment":{"url":"https://api.github.com/repos/Coursemology/coursemology2/issues/comments/194070287","html_url":"https://github.com/Coursemology/coursemology2/pull/880#issuecomment-194070287","issue_url":"https://api.github.com/repos/Coursemology/coursemology2/issues/880","id":194070287,"user":{"login":"allenwq","id":4983239,"avatar_url":"https://avatars.githubusercontent.com/u/4983239?v=3","gravatar_id":"","url":"https://api.github.com/users/allenwq","html_url":"https://github.com/allenwq","followers_url":"https://api.github.com/users/allenwq/followers","following_url":"https://api.github.com/users/allenwq/following{/other_user}","gists_url":"https://api.github.com/users/allenwq/gists{/gist_id}","starred_url":"https://api.github.com/users/allenwq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenwq/subscriptions","organizations_url":"https://api.github.com/users/allenwq/orgs","repos_url":"https://api.github.com/users/allenwq/repos","events_url":"https://api.github.com/users/allenwq/events{/privacy}","received_events_url":"https://api.github.com/users/allenwq/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T02:10:24Z","updated_at":"2016-03-09T02:10:24Z","body":"I think we can make attachments completely private, thus whenever we want to read the attachment we read its reference, methods like `contents` will be delegated to attachment.\r\n\r\nFactories for attachments will be added, but their hashes will be fake ( just a random value)."}}