{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/RTVS/pulls/comments/80834770","pull_request_review_id":1860873,"id":80834770,"diff_hunk":"@@ -21,34 +29,76 @@\n namespace Microsoft.VisualStudio.R.Package.ProjectSystem.Commands {\n     [ExportCommandGroup(\"AD87578C-B324-44DC-A12A-B01A6ED5C6E3\")]\n     [AppliesTo(ProjectConstants.RtvsProjectCapability)]\n-    internal sealed class SourceFilesCommand : ICommandGroupHandler {\n+    internal sealed class SourceFilesCommand : IAsyncCommandGroupHandler {\n+        private readonly ConfiguredProject _configuredProject;\n         private IRInteractiveWorkflowProvider _interactiveWorkflowProvider;\n \n         [ImportingConstructor]\n-        public SourceFilesCommand(IRInteractiveWorkflowProvider interactiveWorkflowProvider)  {\n+        public SourceFilesCommand(ConfiguredProject configuredProject, IRInteractiveWorkflowProvider interactiveWorkflowProvider)  {\n+            _configuredProject = configuredProject;\n             _interactiveWorkflowProvider = interactiveWorkflowProvider;\n         }\n \n-        public CommandStatusResult GetCommandStatus(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, string commandText, CommandStatus progressiveStatus) {\n+        public Task<CommandStatusResult> GetCommandStatusAsync(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, string commandText, CommandStatus progressiveStatus) {\n             if ((commandId == RPackageCommandId.icmdSourceSelectedFiles || commandId == RPackageCommandId.icmdSourceSelectedFilesWithEcho) && nodes.GetSelectedNodesPaths().Count() > 0) {\n                 foreach (var n in nodes) {\n                     if (n.IsFolder || !Path.GetExtension(n.FilePath).EqualsIgnoreCase(\".r\")) { \n-                        return CommandStatusResult.Unhandled;\n+                        return Task.FromResult(CommandStatusResult.Unhandled);\n                     }\n                 }\n-                return new CommandStatusResult(true, commandText, CommandStatus.Enabled | CommandStatus.Supported);\n+                return Task.FromResult(new CommandStatusResult(true, commandText, CommandStatus.Enabled | CommandStatus.Supported));\n             }\n-            return CommandStatusResult.Unhandled;\n+            return Task.FromResult(CommandStatusResult.Unhandled);\n         }\n \n-        public bool TryHandleCommand(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut) {\n+        public async Task<bool> TryHandleCommandAsync(IImmutableSet<IProjectTree> nodes, long commandId, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut) {\n             if (commandId == RPackageCommandId.icmdSourceSelectedFiles || commandId == RPackageCommandId.icmdSourceSelectedFilesWithEcho) {\n-                var rFiles = nodes.GetSelectedNodesPaths().Where(x =>\n-                               Path.GetExtension(x).EqualsIgnoreCase(\".r\") &&\n-                               File.Exists(x));\n                 bool echo = commandId == RPackageCommandId.icmdSourceSelectedFilesWithEcho;\n-                _interactiveWorkflowProvider.GetOrCreate().Operations.SourceFiles(rFiles, echo);\n-                return true;\n+                IEnumerable<string> rFiles = Enumerable.Empty<string>();\n+\n+                IFileSystem fs = new FileSystem();\n+                var workflow = _interactiveWorkflowProvider.GetOrCreate();\n+                try {\n+                    var session = workflow.RSession;\n+                    if (session.IsRemote) {\n+                        var properties = _configuredProject.Services.ExportProvider.GetExportedValue<ProjectProperties>();\n+                        \n+                        string projectDir = Path.GetDirectoryName(_configuredProject.UnconfiguredProject.FullPath);\n+                        string projectName = properties.GetProjectName();\n+                        string remotePath = await properties.GetRemoteProjectPathAsync();\n+\n+                        var files = nodes.GetSelectedNodesPaths().Where(x =>\n+                                   Path.GetExtension(x).EqualsIgnoreCase(RContentTypeDefinition.FileExtension) &&\n+                                   fs.FileExists(x));\n+                        workflow.ActiveWindow.InteractiveWindow.WriteLine(Resources.Info_CompressingFiles);\n+                        \n+                        string compressedFilePath = fs.CompressFiles(files, projectDir, new Progress<string>((p) => {\n+                            workflow.ActiveWindow.InteractiveWindow.WriteLine(string.Format(Resources.Info_LocalFilePath, p));\n+                            string dest = p.MakeRelativePath(projectDir).ProjectRelativePathToRemoteProjectPath(remotePath, projectName);\n+                            workflow.ActiveWindow.InteractiveWindow.WriteLine(string.Format(Resources.Info_RemoteDestination, dest));\n+\n+                        }), CancellationToken.None);\n+\n+                        using (var fts = new DataTransferSession(session, fs)) {\n+                            workflow.ActiveWindow.InteractiveWindow.WriteLine(Resources.Info_TransferingFiles);\n+                            var remoteFile = await fts.SendFileAsync(compressedFilePath);\n+                            await session.EvaluateAsync<string>($\"rtvs:::save_to_project_folder({remoteFile.Id}, {projectName.ToRStringLiteral()}, '{remotePath.ToRPath()}')\", REvaluationKind.Normal);\n+                            workflow.ActiveWindow.InteractiveWindow.WriteLine(Resources.Info_TransferingFilesDone);\n+                        }\n+\n+                        rFiles = files.Select(p => p.MakeRelativePath(projectDir).ProjectRelativePathToRemoteProjectPath(remotePath, projectName));\n+                    } else {\n+                        rFiles = nodes.GetSelectedNodesPaths().Where(x =>\n+                                   Path.GetExtension(x).EqualsIgnoreCase(RContentTypeDefinition.FileExtension) &&\n+                                   fs.FileExists(x));\n+                    }\n+\n+                    workflow.Operations.SourceFiles(rFiles, echo);\n+                    return true;\n+                } catch (RHostDisconnectedException) {","path":"src/Package/Impl/ProjectSystem/Commands/SourceFilesCommand.cs","position":null,"original_position":103,"commit_id":"c6db235697769011b9df62341dc467117132ba70","original_commit_id":"b8a039cfb4a39f4f05a2e65456e017cd5df07c1e","user":{"login":"karthiknadig","id":3840081,"avatar_url":"https://avatars.githubusercontent.com/u/3840081?v=3","gravatar_id":"","url":"https://api.github.com/users/karthiknadig","html_url":"https://github.com/karthiknadig","followers_url":"https://api.github.com/users/karthiknadig/followers","following_url":"https://api.github.com/users/karthiknadig/following{/other_user}","gists_url":"https://api.github.com/users/karthiknadig/gists{/gist_id}","starred_url":"https://api.github.com/users/karthiknadig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karthiknadig/subscriptions","organizations_url":"https://api.github.com/users/karthiknadig/orgs","repos_url":"https://api.github.com/users/karthiknadig/repos","events_url":"https://api.github.com/users/karthiknadig/events{/privacy}","received_events_url":"https://api.github.com/users/karthiknadig/received_events","type":"User","site_admin":false},"body":"Added a catch for IOException\r\n\r\n---\r\nIn reply to: [80751801](https://github.com/Microsoft/RTVS/pull/2405#discussion_r80751801) [](ancestors = 80751801)","created_at":"2016-09-28T02:41:52Z","updated_at":"2016-09-28T02:41:52Z","html_url":"https://github.com/Microsoft/RTVS/pull/2405#discussion_r80834770","pull_request_url":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/RTVS/pulls/comments/80834770"},"html":{"href":"https://github.com/Microsoft/RTVS/pull/2405#discussion_r80834770"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405","id":86666766,"html_url":"https://github.com/Microsoft/RTVS/pull/2405","diff_url":"https://github.com/Microsoft/RTVS/pull/2405.diff","patch_url":"https://github.com/Microsoft/RTVS/pull/2405.patch","issue_url":"https://api.github.com/repos/Microsoft/RTVS/issues/2405","number":2405,"state":"open","locked":false,"title":"Remote Send files and source selected files.","user":{"login":"karthiknadig","id":3840081,"avatar_url":"https://avatars.githubusercontent.com/u/3840081?v=3","gravatar_id":"","url":"https://api.github.com/users/karthiknadig","html_url":"https://github.com/karthiknadig","followers_url":"https://api.github.com/users/karthiknadig/followers","following_url":"https://api.github.com/users/karthiknadig/following{/other_user}","gists_url":"https://api.github.com/users/karthiknadig/gists{/gist_id}","starred_url":"https://api.github.com/users/karthiknadig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karthiknadig/subscriptions","organizations_url":"https://api.github.com/users/karthiknadig/orgs","repos_url":"https://api.github.com/users/karthiknadig/repos","events_url":"https://api.github.com/users/karthiknadig/events{/privacy}","received_events_url":"https://api.github.com/users/karthiknadig/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-25T23:38:40Z","updated_at":"2016-09-28T02:41:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd2aa2dee193be08db6909ef4365bf0cfff05571","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405/commits","review_comments_url":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405/comments","review_comment_url":"https://api.github.com/repos/Microsoft/RTVS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/RTVS/issues/2405/comments","statuses_url":"https://api.github.com/repos/Microsoft/RTVS/statuses/c6db235697769011b9df62341dc467117132ba70","head":{"label":"karthiknadig:remote-feat","ref":"remote-feat","sha":"c6db235697769011b9df62341dc467117132ba70","user":{"login":"karthiknadig","id":3840081,"avatar_url":"https://avatars.githubusercontent.com/u/3840081?v=3","gravatar_id":"","url":"https://api.github.com/users/karthiknadig","html_url":"https://github.com/karthiknadig","followers_url":"https://api.github.com/users/karthiknadig/followers","following_url":"https://api.github.com/users/karthiknadig/following{/other_user}","gists_url":"https://api.github.com/users/karthiknadig/gists{/gist_id}","starred_url":"https://api.github.com/users/karthiknadig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karthiknadig/subscriptions","organizations_url":"https://api.github.com/users/karthiknadig/orgs","repos_url":"https://api.github.com/users/karthiknadig/repos","events_url":"https://api.github.com/users/karthiknadig/events{/privacy}","received_events_url":"https://api.github.com/users/karthiknadig/received_events","type":"User","site_admin":false},"repo":{"id":58878017,"name":"RTVS","full_name":"karthiknadig/RTVS","owner":{"login":"karthiknadig","id":3840081,"avatar_url":"https://avatars.githubusercontent.com/u/3840081?v=3","gravatar_id":"","url":"https://api.github.com/users/karthiknadig","html_url":"https://github.com/karthiknadig","followers_url":"https://api.github.com/users/karthiknadig/followers","following_url":"https://api.github.com/users/karthiknadig/following{/other_user}","gists_url":"https://api.github.com/users/karthiknadig/gists{/gist_id}","starred_url":"https://api.github.com/users/karthiknadig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karthiknadig/subscriptions","organizations_url":"https://api.github.com/users/karthiknadig/orgs","repos_url":"https://api.github.com/users/karthiknadig/repos","events_url":"https://api.github.com/users/karthiknadig/events{/privacy}","received_events_url":"https://api.github.com/users/karthiknadig/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/karthiknadig/RTVS","description":"R Tools for Visual Studio.","fork":true,"url":"https://api.github.com/repos/karthiknadig/RTVS","forks_url":"https://api.github.com/repos/karthiknadig/RTVS/forks","keys_url":"https://api.github.com/repos/karthiknadig/RTVS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/karthiknadig/RTVS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/karthiknadig/RTVS/teams","hooks_url":"https://api.github.com/repos/karthiknadig/RTVS/hooks","issue_events_url":"https://api.github.com/repos/karthiknadig/RTVS/issues/events{/number}","events_url":"https://api.github.com/repos/karthiknadig/RTVS/events","assignees_url":"https://api.github.com/repos/karthiknadig/RTVS/assignees{/user}","branches_url":"https://api.github.com/repos/karthiknadig/RTVS/branches{/branch}","tags_url":"https://api.github.com/repos/karthiknadig/RTVS/tags","blobs_url":"https://api.github.com/repos/karthiknadig/RTVS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/karthiknadig/RTVS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/karthiknadig/RTVS/git/refs{/sha}","trees_url":"https://api.github.com/repos/karthiknadig/RTVS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/karthiknadig/RTVS/statuses/{sha}","languages_url":"https://api.github.com/repos/karthiknadig/RTVS/languages","stargazers_url":"https://api.github.com/repos/karthiknadig/RTVS/stargazers","contributors_url":"https://api.github.com/repos/karthiknadig/RTVS/contributors","subscribers_url":"https://api.github.com/repos/karthiknadig/RTVS/subscribers","subscription_url":"https://api.github.com/repos/karthiknadig/RTVS/subscription","commits_url":"https://api.github.com/repos/karthiknadig/RTVS/commits{/sha}","git_commits_url":"https://api.github.com/repos/karthiknadig/RTVS/git/commits{/sha}","comments_url":"https://api.github.com/repos/karthiknadig/RTVS/comments{/number}","issue_comment_url":"https://api.github.com/repos/karthiknadig/RTVS/issues/comments{/number}","contents_url":"https://api.github.com/repos/karthiknadig/RTVS/contents/{+path}","compare_url":"https://api.github.com/repos/karthiknadig/RTVS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/karthiknadig/RTVS/merges","archive_url":"https://api.github.com/repos/karthiknadig/RTVS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/karthiknadig/RTVS/downloads","issues_url":"https://api.github.com/repos/karthiknadig/RTVS/issues{/number}","pulls_url":"https://api.github.com/repos/karthiknadig/RTVS/pulls{/number}","milestones_url":"https://api.github.com/repos/karthiknadig/RTVS/milestones{/number}","notifications_url":"https://api.github.com/repos/karthiknadig/RTVS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/karthiknadig/RTVS/labels{/name}","releases_url":"https://api.github.com/repos/karthiknadig/RTVS/releases{/id}","deployments_url":"https://api.github.com/repos/karthiknadig/RTVS/deployments","created_at":"2016-05-15T18:42:08Z","updated_at":"2016-05-15T18:42:16Z","pushed_at":"2016-09-28T02:38:02Z","git_url":"git://github.com/karthiknadig/RTVS.git","ssh_url":"git@github.com:karthiknadig/RTVS.git","clone_url":"https://github.com/karthiknadig/RTVS.git","svn_url":"https://github.com/karthiknadig/RTVS","homepage":null,"size":51210,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"Microsoft:master","ref":"master","sha":"b46f8c5609c74953cf2cafa4c6a4f0fc435c1619","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":38640473,"name":"RTVS","full_name":"Microsoft/RTVS","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/RTVS","description":"R Tools for Visual Studio.","fork":false,"url":"https://api.github.com/repos/Microsoft/RTVS","forks_url":"https://api.github.com/repos/Microsoft/RTVS/forks","keys_url":"https://api.github.com/repos/Microsoft/RTVS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/RTVS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/RTVS/teams","hooks_url":"https://api.github.com/repos/Microsoft/RTVS/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/RTVS/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/RTVS/events","assignees_url":"https://api.github.com/repos/Microsoft/RTVS/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/RTVS/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/RTVS/tags","blobs_url":"https://api.github.com/repos/Microsoft/RTVS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/RTVS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/RTVS/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/RTVS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/RTVS/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/RTVS/languages","stargazers_url":"https://api.github.com/repos/Microsoft/RTVS/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/RTVS/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/RTVS/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/RTVS/subscription","commits_url":"https://api.github.com/repos/Microsoft/RTVS/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/RTVS/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/RTVS/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/RTVS/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/RTVS/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/RTVS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/RTVS/merges","archive_url":"https://api.github.com/repos/Microsoft/RTVS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/RTVS/downloads","issues_url":"https://api.github.com/repos/Microsoft/RTVS/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/RTVS/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/RTVS/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/RTVS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/RTVS/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/RTVS/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/RTVS/deployments","created_at":"2015-07-06T19:14:09Z","updated_at":"2016-09-28T01:49:55Z","pushed_at":"2016-09-28T02:38:03Z","git_url":"git://github.com/Microsoft/RTVS.git","ssh_url":"git@github.com:Microsoft/RTVS.git","clone_url":"https://github.com/Microsoft/RTVS.git","svn_url":"https://github.com/Microsoft/RTVS","homepage":null,"size":51586,"stargazers_count":199,"watchers_count":199,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":323,"forks":54,"open_issues":323,"watchers":199,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405"},"html":{"href":"https://github.com/Microsoft/RTVS/pull/2405"},"issue":{"href":"https://api.github.com/repos/Microsoft/RTVS/issues/2405"},"comments":{"href":"https://api.github.com/repos/Microsoft/RTVS/issues/2405/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/RTVS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/RTVS/pulls/2405/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/RTVS/statuses/c6db235697769011b9df62341dc467117132ba70"}}}}
{"actor":{"display_login":"karthiknadig"}}