/// <summary> /// Sets the hash algorithm on the server to be used with the HASH command asynchronously. /// </summary> internal async Task SetHashAlgorithmInternalAsync(FtpHashAlgorithm algorithm, CancellationToken token = default(CancellationToken)) { FtpReply reply; // skip setting the hash algo if the server is already configured to it if (_LastHashAlgo == algorithm) { return; } if ((HashAlgorithms & algorithm) != algorithm) { throw new NotImplementedException("The hash algorithm " + algorithm.ToString() + " was not advertised by the server."); } string algoName = HashAlgos.PrintToString(algorithm); if (!(reply = await ExecuteAsync("OPTS HASH " + algoName, token)).Success) { throw new FtpCommandException(reply); } // save the current hash algo so no need to repeat this command _LastHashAlgo = algorithm; }
/// <summary> /// Sets the hash algorithm on the server to use for the HASH command. /// </summary> internal void SetHashAlgorithmInternal(FtpHashAlgorithm algorithm) { FtpReply reply; // skip setting the hash algo if the server is already configured to it if (_LastHashAlgo == algorithm) { return; } #if !CORE14 lock (m_lock) { #endif if ((HashAlgorithms & algorithm) != algorithm) { throw new NotImplementedException("The hash algorithm " + algorithm.ToString() + " was not advertised by the server."); } string algoName = HashAlgos.PrintToString(algorithm); if (!(reply = Execute("OPTS HASH " + algoName)).Success) { throw new FtpCommandException(reply); } // save the current hash algo so no need to repeat this command _LastHashAlgo = algorithm; #if !CORE14 } #endif }