Skip to content
This repository was archived by the owner on Dec 22, 2018. It is now read-only.

SFTP and More#78

Open
KitsuneDev wants to merge 9 commits intozlepper:masterfrom
KitsuneDev:master
Open

SFTP and More#78
KitsuneDev wants to merge 9 commits intozlepper:masterfrom
KitsuneDev:master

Conversation

@KitsuneDev
Copy link
Copy Markdown

@KitsuneDev KitsuneDev commented Sep 6, 2017

Hey Guys!

SFTP: Faster*, Safer and Easier to Setup

*It's faster only sometimes

This PR:

  • Adds SFTP
  • Does some refactorings
  • Improves FTP error messages on test.

TESTED

@zlepper
Copy link
Copy Markdown
Owner

zlepper commented Sep 6, 2017

Awesome!!!!

And make sure to also test on Linux under mono.

@KitsuneDev
Copy link
Copy Markdown
Author

Done! If you want, please add me to contributors so I can do some more refactoring / add more features / solve issues 😄

{
SFTP sftp = new SFTP(host.Text, user.Text, password.Text, int.Parse(port.Text));
sftp.UploadSFTPFile(
Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, just generate a test file with some random content in it, we don't want to ship any more data to the client than needed. Use guids to avoid file name conflicts

UploadToFTPServer.Checked = false;
return;
}
}*/
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these comments shouldn't need to be in the source anymore

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought It would be better to let it there, so if you wanted do display a message like you did with ftp. What do you think about it?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either show the message or remove the code, leaving the code there would just cause confusion.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will add a message.

Comment thread TechnicSolderHelper/TestFile.txt Outdated
@@ -0,0 +1 @@
Upload OK No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, really don't like that we have to ship this file around.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll generate it

Copy link
Copy Markdown
Owner

@zlepper zlepper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the added comments, I especially don't like the idea of shipping around a txt file with the install to test upload, much better to just generate it, and delete it as needed. And use Guid.NewGuid() to get a random string to the name, to avoid conflicts with other files named test

@zlepper
Copy link
Copy Markdown
Owner

zlepper commented Sep 6, 2017

Also, did you test it on linux?

@KitsuneDev
Copy link
Copy Markdown
Author

KitsuneDev commented Sep 6, 2017

I didn't test on linux but, since we're using SSH.NET, it seems thet everything will work

@KitsuneDev
Copy link
Copy Markdown
Author

Done

Copy link
Copy Markdown
Owner

@zlepper zlepper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a couple of things that needs to be correctly, but they are mostly small and stylistic

this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(205, 13);
this.label6.TabIndex = 13;
this.label6.Text = "--> Make sure there is no file named \"test\"";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be removed

System.IO.StreamWriter file = new System.IO.StreamWriter(filePath);
file.WriteLine(lines);

file.Close();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files should really be opening using the "using" pattern https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement, as this will ensure automatic closing of the file. As i haven't done it everywhere in the project, then i will not stop the pull request just from this.
I'm writing this comments mostly to make sure you learn it for future reference :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks. I knew about it, but I don't like using statements, I prefer .Dispose();. Will do it now too.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for using the using statement is that if something goes horribly wrong and crashes before you call dispose, then the file is still closed, and not left hanging around.


// Write the string to a file.
Guid g = Guid.NewGuid();
string uuid = Convert.ToBase64String(g.ToByteArray());
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, just to string guid = Guid.NewGuid().ToString() it will have the same result, and you won't get the extra base64 chars

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will do it

@zlepper
Copy link
Copy Markdown
Owner

zlepper commented Sep 6, 2017

Looking good so far. I will still need to confirm manually that everything works on linux, but that will not be today.

@KitsuneDev
Copy link
Copy Markdown
Author

Done (Again)

@zlepper
Copy link
Copy Markdown
Owner

zlepper commented Sep 7, 2017

Looks good to me now. During the weekend I will get it merged, provided it works on Linux.

@Arzte
Copy link
Copy Markdown

Arzte commented Nov 4, 2017

Bump for linux testing of this PR

@KitsuneDev
Copy link
Copy Markdown
Author

KitsuneDev commented Nov 5, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants