{"action":"closed","number":27,"pull_request":{"url":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/27","id":34263727,"html_url":"https://github.com/xing/paperclip-storage-ftp/pull/27","diff_url":"https://github.com/xing/paperclip-storage-ftp/pull/27.diff","patch_url":"https://github.com/xing/paperclip-storage-ftp/pull/27.patch","issue_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/issues/27","number":27,"state":"closed","locked":false,"title":"Reduce number of FTP commands","user":{"login":"toao","id":80499,"avatar_url":"https://avatars.githubusercontent.com/u/80499?v=3","gravatar_id":"","url":"https://api.github.com/users/toao","html_url":"https://github.com/toao","followers_url":"https://api.github.com/users/toao/followers","following_url":"https://api.github.com/users/toao/following{/other_user}","gists_url":"https://api.github.com/users/toao/gists{/gist_id}","starred_url":"https://api.github.com/users/toao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toao/subscriptions","organizations_url":"https://api.github.com/users/toao/orgs","repos_url":"https://api.github.com/users/toao/repos","events_url":"https://api.github.com/users/toao/events{/privacy}","received_events_url":"https://api.github.com/users/toao/received_events","type":"User","site_admin":false},"body":"Right now for every uploaded file its complete path is traversed and MKDIR is called on each level. That's not very efficient and can be improved, especially if several files are uploaded in one go.\r\n\r\nThis PR reduces the number of executed FTP commands by\r\n* checking if the directory of the given file already exists and skipping MKDIR if applicable\r\n* calculating the missing directories within the path beforehand and only creating the ones needed\r\n\r\nYou get the most benefit from this fix when several files are deeply nested within a common parent directory structure. That's often the case for image uploads that create several versions, e.g.\r\n```\r\n/img/user/profile/000/000/001/original.jpg\r\n/img/user/profile/000/000/001/small.jpg\r\n/img/user/profile/000/000/001/thumb.jpg\r\n```\r\n\r\n@boosty Let me know what you think and if I need to squash some commits before the PR can be merged.\r\n\r\nCheers,\r\nRaik","created_at":"2015-04-28T12:59:36Z","updated_at":"2015-10-20T16:45:33Z","closed_at":"2015-10-20T16:45:33Z","merged_at":"2015-10-20T16:45:33Z","merge_commit_sha":"18a3243553ccc2d48dae58f71345d61892e5bb68","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/27/commits","review_comments_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/27/comments","review_comment_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/issues/27/comments","statuses_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/statuses/f67b64362e41a5115459b3d8c2e5cf5eebd3e3c3","head":{"label":"toao:put_file_performance_fix","ref":"put_file_performance_fix","sha":"f67b64362e41a5115459b3d8c2e5cf5eebd3e3c3","user":{"login":"toao","id":80499,"avatar_url":"https://avatars.githubusercontent.com/u/80499?v=3","gravatar_id":"","url":"https://api.github.com/users/toao","html_url":"https://github.com/toao","followers_url":"https://api.github.com/users/toao/followers","following_url":"https://api.github.com/users/toao/following{/other_user}","gists_url":"https://api.github.com/users/toao/gists{/gist_id}","starred_url":"https://api.github.com/users/toao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toao/subscriptions","organizations_url":"https://api.github.com/users/toao/orgs","repos_url":"https://api.github.com/users/toao/repos","events_url":"https://api.github.com/users/toao/events{/privacy}","received_events_url":"https://api.github.com/users/toao/received_events","type":"User","site_admin":false},"repo":{"id":34387085,"name":"paperclip-storage-ftp","full_name":"toao/paperclip-storage-ftp","owner":{"login":"toao","id":80499,"avatar_url":"https://avatars.githubusercontent.com/u/80499?v=3","gravatar_id":"","url":"https://api.github.com/users/toao","html_url":"https://github.com/toao","followers_url":"https://api.github.com/users/toao/followers","following_url":"https://api.github.com/users/toao/following{/other_user}","gists_url":"https://api.github.com/users/toao/gists{/gist_id}","starred_url":"https://api.github.com/users/toao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toao/subscriptions","organizations_url":"https://api.github.com/users/toao/orgs","repos_url":"https://api.github.com/users/toao/repos","events_url":"https://api.github.com/users/toao/events{/privacy}","received_events_url":"https://api.github.com/users/toao/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/toao/paperclip-storage-ftp","description":"Allow Paperclip attachments to be stored on FTP servers","fork":true,"url":"https://api.github.com/repos/toao/paperclip-storage-ftp","forks_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/forks","keys_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/teams","hooks_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/hooks","issue_events_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/issues/events{/number}","events_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/events","assignees_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/assignees{/user}","branches_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/branches{/branch}","tags_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/tags","blobs_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/git/refs{/sha}","trees_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/statuses/{sha}","languages_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/languages","stargazers_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/stargazers","contributors_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/contributors","subscribers_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/subscribers","subscription_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/subscription","commits_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/commits{/sha}","git_commits_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/git/commits{/sha}","comments_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/comments{/number}","issue_comment_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/issues/comments{/number}","contents_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/contents/{+path}","compare_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/merges","archive_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/downloads","issues_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/issues{/number}","pulls_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/pulls{/number}","milestones_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/milestones{/number}","notifications_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/labels{/name}","releases_url":"https://api.github.com/repos/toao/paperclip-storage-ftp/releases{/id}","created_at":"2015-04-22T11:43:31Z","updated_at":"2015-04-22T11:43:31Z","pushed_at":"2015-07-28T08:35:35Z","git_url":"git://github.com/toao/paperclip-storage-ftp.git","ssh_url":"git@github.com:toao/paperclip-storage-ftp.git","clone_url":"https://github.com/toao/paperclip-storage-ftp.git","svn_url":"https://github.com/toao/paperclip-storage-ftp","homepage":"","size":2543,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xing:master","ref":"master","sha":"c23cb73cb2fbf7164cfd32aab38e587d934ab6bf","user":{"login":"xing","id":27901,"avatar_url":"https://avatars.githubusercontent.com/u/27901?v=3","gravatar_id":"","url":"https://api.github.com/users/xing","html_url":"https://github.com/xing","followers_url":"https://api.github.com/users/xing/followers","following_url":"https://api.github.com/users/xing/following{/other_user}","gists_url":"https://api.github.com/users/xing/gists{/gist_id}","starred_url":"https://api.github.com/users/xing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xing/subscriptions","organizations_url":"https://api.github.com/users/xing/orgs","repos_url":"https://api.github.com/users/xing/repos","events_url":"https://api.github.com/users/xing/events{/privacy}","received_events_url":"https://api.github.com/users/xing/received_events","type":"Organization","site_admin":false},"repo":{"id":5965834,"name":"paperclip-storage-ftp","full_name":"xing/paperclip-storage-ftp","owner":{"login":"xing","id":27901,"avatar_url":"https://avatars.githubusercontent.com/u/27901?v=3","gravatar_id":"","url":"https://api.github.com/users/xing","html_url":"https://github.com/xing","followers_url":"https://api.github.com/users/xing/followers","following_url":"https://api.github.com/users/xing/following{/other_user}","gists_url":"https://api.github.com/users/xing/gists{/gist_id}","starred_url":"https://api.github.com/users/xing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xing/subscriptions","organizations_url":"https://api.github.com/users/xing/orgs","repos_url":"https://api.github.com/users/xing/repos","events_url":"https://api.github.com/users/xing/events{/privacy}","received_events_url":"https://api.github.com/users/xing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xing/paperclip-storage-ftp","description":"Allow Paperclip attachments to be stored on FTP servers","fork":false,"url":"https://api.github.com/repos/xing/paperclip-storage-ftp","forks_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/forks","keys_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/teams","hooks_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/hooks","issue_events_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/issues/events{/number}","events_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/events","assignees_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/assignees{/user}","branches_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/branches{/branch}","tags_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/tags","blobs_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/git/refs{/sha}","trees_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/statuses/{sha}","languages_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/languages","stargazers_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/stargazers","contributors_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/contributors","subscribers_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/subscribers","subscription_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/subscription","commits_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/commits{/sha}","git_commits_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/git/commits{/sha}","comments_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/comments{/number}","issue_comment_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/issues/comments{/number}","contents_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/contents/{+path}","compare_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/merges","archive_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/downloads","issues_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/issues{/number}","pulls_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls{/number}","milestones_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/milestones{/number}","notifications_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/labels{/name}","releases_url":"https://api.github.com/repos/xing/paperclip-storage-ftp/releases{/id}","created_at":"2012-09-26T13:01:11Z","updated_at":"2015-09-26T16:21:59Z","pushed_at":"2015-10-20T16:45:33Z","git_url":"git://github.com/xing/paperclip-storage-ftp.git","ssh_url":"git@github.com:xing/paperclip-storage-ftp.git","clone_url":"https://github.com/xing/paperclip-storage-ftp.git","svn_url":"https://github.com/xing/paperclip-storage-ftp","homepage":"","size":2867,"stargazers_count":38,"watchers_count":38,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":0,"forks":12,"open_issues":0,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/27"},"html":{"href":"https://github.com/xing/paperclip-storage-ftp/pull/27"},"issue":{"href":"https://api.github.com/repos/xing/paperclip-storage-ftp/issues/27"},"comments":{"href":"https://api.github.com/repos/xing/paperclip-storage-ftp/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xing/paperclip-storage-ftp/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/xing/paperclip-storage-ftp/statuses/f67b64362e41a5115459b3d8c2e5cf5eebd3e3c3"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"boosty","id":4270,"avatar_url":"https://avatars.githubusercontent.com/u/4270?v=3","gravatar_id":"","url":"https://api.github.com/users/boosty","html_url":"https://github.com/boosty","followers_url":"https://api.github.com/users/boosty/followers","following_url":"https://api.github.com/users/boosty/following{/other_user}","gists_url":"https://api.github.com/users/boosty/gists{/gist_id}","starred_url":"https://api.github.com/users/boosty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boosty/subscriptions","organizations_url":"https://api.github.com/users/boosty/orgs","repos_url":"https://api.github.com/users/boosty/repos","events_url":"https://api.github.com/users/boosty/events{/privacy}","received_events_url":"https://api.github.com/users/boosty/received_events","type":"User","site_admin":false},"comments":11,"review_comments":10,"commits":10,"additions":220,"deletions":38,"changed_files":6}}