Skip to content

Commit

Permalink
Merge pull request #2 from robinrodricks/master
Browse files Browse the repository at this point in the history
Upstream Merge
  • Loading branch information
n0ix authored Feb 15, 2020
2 parents 5194e17 + 51a5377 commit b64aed5
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 95 deletions.
14 changes: 7 additions & 7 deletions FluentFTP/Client/FtpClient_Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public virtual void Dispose() {

// Fix: Hard catch and suppress all exceptions during disposing as there are constant issues with this method
try {
LogFunc("Dispose");
LogFunc(nameof(Dispose));
LogStatus(FtpTraceLevel.Verbose, "Disposing FtpClient object...");
}
catch (Exception ex) {
Expand Down Expand Up @@ -291,7 +291,7 @@ public virtual void Connect() {
lock (m_lock) {
#endif

LogFunc("Connect");
LogFunc(nameof(Connect));

if (IsDisposed) {
throw new ObjectDisposedException("This FtpClient object has been disposed. It is no longer accessible.");
Expand Down Expand Up @@ -652,7 +652,7 @@ protected virtual void GetFeatures(FtpReply reply) {
FtpServerSpecificHandler.GetFeatures(this, m_capabilities, ref m_hashAlgorithms, reply.InfoMessages.Split('\n'));
}

#if !CORE
#if !ASYNC
private delegate void AsyncConnect();

/// <summary>
Expand Down Expand Up @@ -729,7 +729,7 @@ public List<FtpProfile> AutoDetect(bool firstOnly = true) {
#if !CORE14
lock (m_lock) {
#endif
LogFunc("AutoDetect", new object[] { firstOnly });
LogFunc(nameof(AutoDetect), new object[] { firstOnly });

if (IsDisposed) {
throw new ObjectDisposedException("This FtpClient object has been disposed. It is no longer accessible.");
Expand Down Expand Up @@ -875,7 +875,7 @@ private void LoadProfile(FtpProfile profile) {
/// Returns the FtpProfile if the connection succeeded, or null if it failed.
/// </summary>
public FtpProfile AutoConnect() {
LogFunc("AutoConnect");
LogFunc(nameof(AutoConnect));

// detect the first available connection profile
var results = AutoDetect();
Expand Down Expand Up @@ -911,7 +911,7 @@ public FtpProfile AutoConnect() {
/// Returns the FtpProfile if the connection succeeded, or null if it failed.
/// </summary>
public async Task<FtpProfile> AutoConnectAsync(CancellationToken token = default(CancellationToken)) {
LogFunc("AutoConnectAsync");
LogFunc(nameof(AutoConnectAsync));

// detect the first available connection profile
var results = AutoDetect();
Expand Down Expand Up @@ -1042,7 +1042,7 @@ public virtual void Disconnect() {
#endif
}

#if !CORE
#if !ASYNC
private delegate void AsyncDisconnect();

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions FluentFTP/Client/FtpClient_FileDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public int DownloadFiles(string localDir, IEnumerable<string> remotePaths, FtpLo
throw new ArgumentException("Required parameter is null or blank.", "localDir");
}

LogFunc("DownloadFiles", new object[] { localDir, remotePaths, existsMode, verifyOptions });
LogFunc(nameof(DownloadFiles), new object[] { localDir, remotePaths, existsMode, verifyOptions });

var errorEncountered = false;
var successfulDownloads = new List<string>();
Expand Down Expand Up @@ -170,7 +170,7 @@ public async Task<int> DownloadFilesAsync(string localDir, IEnumerable<string> r
throw new ArgumentException("Required parameter is null or blank.", "localDir");
}

LogFunc("DownloadFilesAsync", new object[] { localDir, remotePaths, existsMode, verifyOptions });
LogFunc(nameof(DownloadFilesAsync), new object[] { localDir, remotePaths, existsMode, verifyOptions });

//check if cancellation was requested and throw to set TaskStatus state to Canceled
token.ThrowIfCancellationRequested();
Expand Down Expand Up @@ -281,7 +281,7 @@ public FtpStatus DownloadFile(string localPath, string remotePath, FtpLocalExist
private FtpStatus DownloadFileToFile(string localPath, string remotePath, FtpLocalExists existsMode, FtpVerify verifyOptions, Action<FtpProgress> progress, FtpProgress metaProgress) {
var outStreamFileMode = FileMode.Create;

LogFunc("DownloadFile", new object[] { localPath, remotePath, existsMode, verifyOptions });
LogFunc(nameof(DownloadFile), new object[] { localPath, remotePath, existsMode, verifyOptions });

// skip downloading if local file size matches
if (existsMode == FtpLocalExists.Append && File.Exists(localPath)) {
Expand Down Expand Up @@ -387,7 +387,7 @@ private async Task<FtpStatus> DownloadFileToFileAsync(string localPath, string r
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("DownloadFileAsync", new object[] { localPath, remotePath, existsMode, verifyOptions });
LogFunc(nameof(DownloadFileAsync), new object[] { localPath, remotePath, existsMode, verifyOptions });


var outStreamFileMode = FileMode.Create;
Expand Down Expand Up @@ -494,7 +494,7 @@ public bool Download(Stream outStream, string remotePath, long restartPosition =
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("Download", new object[] { remotePath });
LogFunc(nameof(Download), new object[] { remotePath });

// download the file from the server
return DownloadFileInternal(null, remotePath, outStream, restartPosition, progress, new FtpProgress(1, 0));
Expand All @@ -516,7 +516,7 @@ public bool Download(out byte[] outBytes, string remotePath, long restartPositio
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("Download", new object[] { remotePath });
LogFunc(nameof(Download), new object[] { remotePath });

outBytes = null;

Expand Down Expand Up @@ -554,7 +554,7 @@ public bool Download(out byte[] outBytes, string remotePath, long restartPositio
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("DownloadAsync", new object[] { remotePath });
LogFunc(nameof(DownloadAsync), new object[] { remotePath });

// download the file from the server
return await DownloadFileInternalAsync(null, remotePath, outStream, restartPosition, progress, token, new FtpProgress(1, 0));
Expand All @@ -576,7 +576,7 @@ public bool Download(out byte[] outBytes, string remotePath, long restartPositio
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("DownloadAsync", new object[] { remotePath });
LogFunc(nameof(DownloadAsync), new object[] { remotePath });

// download the file from the server
using (var outStream = new MemoryStream()) {
Expand Down
36 changes: 18 additions & 18 deletions FluentFTP/Client/FtpClient_FileManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void DeleteFile(string path) {
#if !CORE14
lock (m_lock) {
#endif
LogFunc("DeleteFile", new object[] { path });
LogFunc(nameof(DeleteFile), new object[] { path });

if (!(reply = Execute("DELE " + path.GetFtpPath())).Success) {
throw new FtpCommandException(reply);
Expand All @@ -55,7 +55,7 @@ public void DeleteFile(string path) {
#endif
}

#if !CORE
#if !ASYNC
private delegate void AsyncDeleteFile(string path);

/// <summary>
Expand Down Expand Up @@ -130,7 +130,7 @@ public bool FileExists(string path) {
lock (m_lock) {
#endif

LogFunc("FileExists", new object[] { path });
LogFunc(nameof(FileExists), new object[] { path });

// calc the absolute filepath
path = GetAbsolutePath(path.GetFtpPath());
Expand Down Expand Up @@ -203,7 +203,7 @@ public bool FileExists(string path) {
return null;
}

#if !CORE
#if !ASYNC
private delegate bool AsyncFileExists(string path);

/// <summary>
Expand Down Expand Up @@ -328,7 +328,7 @@ public void Rename(string path, string dest) {
#if !CORE14
lock (m_lock) {
#endif
LogFunc("Rename", new object[] { path, dest });
LogFunc(nameof(Rename), new object[] { path, dest });

// calc the absolute filepaths
path = GetAbsolutePath(path.GetFtpPath());
Expand All @@ -348,7 +348,7 @@ public void Rename(string path, string dest) {
#endif
}

#if !CORE
#if !ASYNC
private delegate void AsyncRename(string path, string dest);

/// <summary>
Expand Down Expand Up @@ -444,7 +444,7 @@ public bool MoveFile(string path, string dest, FtpRemoteExists existsMode = FtpR
throw new ArgumentException("Required parameter is null or blank.", "dest");
}

LogFunc("MoveFile", new object[] { path, dest, existsMode });
LogFunc(nameof(MoveFile), new object[] { path, dest, existsMode });

if (FileExists(path)) {
// check if dest file exists and act accordingly
Expand All @@ -471,7 +471,7 @@ public bool MoveFile(string path, string dest, FtpRemoteExists existsMode = FtpR
return false;
}

#if !CORE
#if !ASYNC
private delegate bool AsyncMoveFile(string path, string dest, FtpRemoteExists existsMode);

/// <summary>
Expand Down Expand Up @@ -579,7 +579,7 @@ public void SetFilePermissions(string path, int permissions) {
#if !CORE14
lock (m_lock) {
#endif
LogFunc("SetFilePermissions", new object[] { path, permissions });
LogFunc(nameof(SetFilePermissions), new object[] { path, permissions });

if (!(reply = Execute("SITE CHMOD " + permissions.ToString() + " " + path.GetFtpPath())).Success) {
throw new FtpCommandException(reply);
Expand Down Expand Up @@ -726,7 +726,7 @@ public FtpListItem GetFilePermissions(string path) {
throw new ArgumentException("Required parameter is null or blank.", "path");
}

LogFunc("GetFilePermissions", new object[] { path });
LogFunc(nameof(GetFilePermissions), new object[] { path });

var fullPath = path.GetFtpPath();
foreach (var i in GetListing(path)) {
Expand Down Expand Up @@ -817,7 +817,7 @@ public FtpListItem DereferenceLink(FtpListItem item) {
/// <returns>FtpListItem, null if the link can't be dereferenced</returns>
/// <example><code source="..\Examples\DereferenceLink.cs" lang="cs" /></example>
public FtpListItem DereferenceLink(FtpListItem item, int recMax) {
LogFunc("DereferenceLink", new object[] { item.FullName, recMax });
LogFunc(nameof(DereferenceLink), new object[] { item.FullName, recMax });

var count = 0;
return DereferenceLink(item, recMax, ref count);
Expand Down Expand Up @@ -869,7 +869,7 @@ private FtpListItem DereferenceLink(FtpListItem item, int recMax, ref int count)
return null;
}

#if !CORE
#if !ASYNC
private delegate FtpListItem AsyncDereferenceLink(FtpListItem item, int recMax);

/// <summary>
Expand Down Expand Up @@ -1008,7 +1008,7 @@ public virtual long GetFileSize(string path) {
throw new ArgumentException("Required parameter is null or blank.", "path");
}

LogFunc("GetFileSize", new object[] { path });
LogFunc(nameof(GetFileSize), new object[] { path });

if (!HasFeature(FtpCapability.SIZE)) {
return -1;
Expand Down Expand Up @@ -1059,7 +1059,7 @@ private void GetFileSizeInternal(string path, FtpSizeReply sizeReply) {
sizeReply.FileSize = length;
}

#if !CORE
#if !ASYNC
private delegate long AsyncGetFileSize(string path);

/// <summary>
Expand Down Expand Up @@ -1174,7 +1174,7 @@ public virtual DateTime GetModifiedTime(string path, FtpDate type = FtpDate.Orig
throw new ArgumentException("Required parameter is null or blank.", "path");
}

LogFunc("GetModifiedTime", new object[] { path, type });
LogFunc(nameof(GetModifiedTime), new object[] { path, type });

var date = DateTime.MinValue;
FtpReply reply;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ public virtual DateTime GetModifiedTime(string path, FtpDate type = FtpDate.Orig
return date;
}

#if !CORE
#if !ASYNC
private delegate DateTime AsyncGetModifiedTime(string path, FtpDate type);

/// <summary>
Expand Down Expand Up @@ -1304,7 +1304,7 @@ public virtual void SetModifiedTime(string path, DateTime date, FtpDate type = F
throw new ArgumentException("Required parameter is null or blank.", "date");
}

LogFunc("SetModifiedTime", new object[] { path, date, type });
LogFunc(nameof(SetModifiedTime), new object[] { path, date, type });

FtpReply reply;

Expand Down Expand Up @@ -1335,7 +1335,7 @@ public virtual void SetModifiedTime(string path, DateTime date, FtpDate type = F
#endif
}

#if !CORE
#if !ASYNC
private delegate void AsyncSetModifiedTime(string path, DateTime date, FtpDate type);

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions FluentFTP/Client/FtpClient_FileUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public int UploadFiles(IEnumerable<string> localPaths, string remoteDir, FtpRemo
throw new ArgumentException("Required parameter is null or blank.", "remoteDir");
}

LogFunc("UploadFiles", new object[] { localPaths, remoteDir, existsMode, createRemoteDir, verifyOptions, errorHandling });
LogFunc(nameof(UploadFiles), new object[] { localPaths, remoteDir, existsMode, createRemoteDir, verifyOptions, errorHandling });

//int count = 0;
var errorEncountered = false;
Expand Down Expand Up @@ -213,7 +213,7 @@ public async Task<int> UploadFilesAsync(IEnumerable<string> localPaths, string r
throw new ArgumentException("Required parameter is null or blank.", "remoteDir");
}

LogFunc("UploadFilesAsync", new object[] { localPaths, remoteDir, existsMode, createRemoteDir, verifyOptions, errorHandling });
LogFunc(nameof(UploadFilesAsync), new object[] { localPaths, remoteDir, existsMode, createRemoteDir, verifyOptions, errorHandling });

//check if cancellation was requested and throw to set TaskStatus state to Canceled
token.ThrowIfCancellationRequested();
Expand Down Expand Up @@ -351,7 +351,7 @@ public FtpStatus UploadFile(string localPath, string remotePath, FtpRemoteExists
private FtpStatus UploadFileFromFile(string localPath, string remotePath, bool createRemoteDir, FtpRemoteExists existsMode,
bool fileExists, bool fileExistsKnown, FtpVerify verifyOptions, Action<FtpProgress> progress, FtpProgress metaProgress) {

LogFunc("UploadFile", new object[] { localPath, remotePath, existsMode, createRemoteDir, verifyOptions });
LogFunc(nameof(UploadFile), new object[] { localPath, remotePath, existsMode, createRemoteDir, verifyOptions });

// skip uploading if the local file does not exist
if (!File.Exists(localPath)) {
Expand Down Expand Up @@ -444,7 +444,7 @@ private async Task<FtpStatus> UploadFileFromFileAsync(string localPath, string r
return FtpStatus.Failed;
}

LogFunc("UploadFileAsync", new object[] { localPath, remotePath, existsMode, createRemoteDir, verifyOptions });
LogFunc(nameof(UploadFileAsync), new object[] { localPath, remotePath, existsMode, createRemoteDir, verifyOptions });

// If retries are allowed set the retry counter to the allowed count
var attemptsLeft = verifyOptions.HasFlag(FtpVerify.Retry) ? m_retryAttempts : 1;
Expand Down Expand Up @@ -509,7 +509,7 @@ public bool Upload(Stream fileStream, string remotePath, FtpRemoteExists existsM
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("Upload", new object[] { remotePath, existsMode, createRemoteDir });
LogFunc(nameof(Upload), new object[] { remotePath, existsMode, createRemoteDir });

// write the file onto the server
return UploadFileInternal(fileStream, null, remotePath, createRemoteDir, existsMode, false, false, progress, new FtpProgress(1, 0));
Expand All @@ -536,7 +536,7 @@ public bool Upload(byte[] fileData, string remotePath, FtpRemoteExists existsMod
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("Upload", new object[] { remotePath, existsMode, createRemoteDir });
LogFunc(nameof(Upload), new object[] { remotePath, existsMode, createRemoteDir });

// write the file onto the server
using (var ms = new MemoryStream(fileData)) {
Expand Down Expand Up @@ -570,7 +570,7 @@ public bool Upload(byte[] fileData, string remotePath, FtpRemoteExists existsMod
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("UploadAsync", new object[] { remotePath, existsMode, createRemoteDir });
LogFunc(nameof(UploadAsync), new object[] { remotePath, existsMode, createRemoteDir });

// write the file onto the server
return await UploadFileInternalAsync(fileStream, null, remotePath, createRemoteDir, existsMode, false, false, progress, token, new FtpProgress(1, 0));
Expand Down Expand Up @@ -599,7 +599,7 @@ public bool Upload(byte[] fileData, string remotePath, FtpRemoteExists existsMod
throw new ArgumentException("Required parameter is null or blank.", "remotePath");
}

LogFunc("UploadAsync", new object[] { remotePath, existsMode, createRemoteDir });
LogFunc(nameof(UploadAsync), new object[] { remotePath, existsMode, createRemoteDir });

// write the file onto the server
using (var ms = new MemoryStream(fileData)) {
Expand Down
Loading

0 comments on commit b64aed5

Please sign in to comment.