{"action":"created","issue":{"url":"https://api.github.com/repos/CollectionFS/Meteor-cfs-s3/issues/44","labels_url":"https://api.github.com/repos/CollectionFS/Meteor-cfs-s3/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/CollectionFS/Meteor-cfs-s3/issues/44/comments","events_url":"https://api.github.com/repos/CollectionFS/Meteor-cfs-s3/issues/44/events","html_url":"https://github.com/CollectionFS/Meteor-cfs-s3/pull/44","id":54887972,"number":44,"title":"completeMultipartUpload fix","user":{"login":"Nlammertyn","id":817010,"avatar_url":"https://avatars.githubusercontent.com/u/817010?v=3","gravatar_id":"","url":"https://api.github.com/users/Nlammertyn","html_url":"https://github.com/Nlammertyn","followers_url":"https://api.github.com/users/Nlammertyn/followers","following_url":"https://api.github.com/users/Nlammertyn/following{/other_user}","gists_url":"https://api.github.com/users/Nlammertyn/gists{/gist_id}","starred_url":"https://api.github.com/users/Nlammertyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nlammertyn/subscriptions","organizations_url":"https://api.github.com/users/Nlammertyn/orgs","repos_url":"https://api.github.com/users/Nlammertyn/repos","events_url":"https://api.github.com/users/Nlammertyn/events{/privacy}","received_events_url":"https://api.github.com/users/Nlammertyn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-20T14:20:00Z","updated_at":"2015-02-10T16:19:12Z","closed_at":"2015-01-20T14:59:41Z","pull_request":{"url":"https://api.github.com/repos/CollectionFS/Meteor-cfs-s3/pulls/44","html_url":"https://github.com/CollectionFS/Meteor-cfs-s3/pull/44","diff_url":"https://github.com/CollectionFS/Meteor-cfs-s3/pull/44.diff","patch_url":"https://github.com/CollectionFS/Meteor-cfs-s3/pull/44.patch"},"body":"The issue was that files larger than 5MB weren't being uploaded correctly (they were finished but they were missing a bit of data at the end) and resulted in an error, that forced the server to restart.\r\n\r\nLine 56 is not fired for the last file as it's size is never greater than the maxSize\r\n\r\nThis means there is no callback on line 115 and the receivedSize isn't being incremented before landing on line 140. Thus the if statement returns true and completeMultipartUpload is being called.\r\n\r\nOnly then the flushChunk on line 70 is called, but since completeMultipartUpload has already been called, it is too late. The file on S3 has been finished without the last chunk and completeMultipartUpload has been called a 2nd time, resulting in a bug as the files have already been deleted.\r\n\r\nThe fix consists of adding a boolean to indicate if the last chunk is calling the flushChunk(). If not the completeMultipartUpload won't be triggered. "},"comment":{"url":"https://api.github.com/repos/CollectionFS/Meteor-cfs-s3/issues/comments/73729095","html_url":"https://github.com/CollectionFS/Meteor-cfs-s3/pull/44#issuecomment-73729095","issue_url":"https://api.github.com/repos/CollectionFS/Meteor-cfs-s3/issues/44","id":73729095,"user":{"login":"aldeed","id":3012067,"avatar_url":"https://avatars.githubusercontent.com/u/3012067?v=3","gravatar_id":"","url":"https://api.github.com/users/aldeed","html_url":"https://github.com/aldeed","followers_url":"https://api.github.com/users/aldeed/followers","following_url":"https://api.github.com/users/aldeed/following{/other_user}","gists_url":"https://api.github.com/users/aldeed/gists{/gist_id}","starred_url":"https://api.github.com/users/aldeed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldeed/subscriptions","organizations_url":"https://api.github.com/users/aldeed/orgs","repos_url":"https://api.github.com/users/aldeed/repos","events_url":"https://api.github.com/users/aldeed/events{/privacy}","received_events_url":"https://api.github.com/users/aldeed/received_events","type":"User","site_admin":false},"created_at":"2015-02-10T16:19:12Z","updated_at":"2015-02-10T16:19:12Z","body":"https://github.com/CollectionFS/Meteor-cfs-s3/releases/tag/v0.1.2"}}