in AdlsDotNetSDK/ADLSClient.cs [574:607]
internal virtual async Task<AdlsOutputStream> CreateFileAsync(string filename, IfExists mode, AdlsArrayPool<byte> bufferPool, int bufferCapacity, string octalPermission = null, bool createParent = true, CancellationToken cancelToken = default(CancellationToken))
{
if (string.IsNullOrEmpty(filename))
{
throw new ArgumentException("Path is null");
}
if (filename.Equals("/"))
{
throw new ArgumentException("Cant create the root");
}
if (ClientLogger.IsTraceEnabled)
{
ClientLogger.Trace($"AdlsStoreClient, Create File {filename} for client {ClientId}");
}
string leaseId = Guid.NewGuid().ToString();
bool overwrite = mode == IfExists.Overwrite;
if (overwrite && _useConditionalCreateWithOverwrite)
{
await CreateFileAtomicallyWithOverWrite(filename, octalPermission, createParent, leaseId, cancelToken).ConfigureAwait(false);
}
else
{
//If we are overwriting any existing file by that name then it doesn't matter to try it again even though the last request is in a inconsistent state
RetryPolicy policy = overwrite ? new ExponentialRetryPolicy() : (RetryPolicy)new NonIdempotentRetryPolicy();
OperationResponse resp = new OperationResponse();
await Core.CreateAsync(filename, overwrite, octalPermission, leaseId, leaseId, createParent, SyncFlag.DATA, null, -1, 0, this, new RequestOptions(GetPerRequestTimeout(), policy), resp, cancelToken).ConfigureAwait(false);
if (!resp.IsSuccessful)
{
throw GetExceptionFromResponse(resp, $"Error in creating file {filename}.");
}
}
return await AdlsOutputStream.GetAdlsOutputStreamAsync(filename, this, true, leaseId, bufferPool, bufferCapacity).ConfigureAwait(false);
}