Hello @Greg-DB
I am getting too_many_write_operations/ at times while uploading a hierarchy of folders each containing a single file.
I am using the UploadSessionStartAsync, UploadSessionAppendV2Async, UploadSessionFinishAsync and UploadAsync APIs to upload files using fragment buffer.
Sometimes all the files get uploaded correctly but in some test runs some files do not get uploaded due to too_many_write_operations error. How do I prevent "too_many_write_operations/" error ?
Error Message:
PathDisplay: /Sandy_Source/Starting folder/SUB1/SUB2/SUB3/SUB4/TriggeredAlarm_Service_Log.txt
Retry Count: 1
too_many_write_operations/...
at Dropbox.Api.DropboxRequestHandler.<RequestJsonString>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Dropbox.Api.DropboxRequestHandler.<RequestJsonStringWithRetry>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Dropbox.Api.DropboxRequestHandler.<Dropbox-Api-Stone-ITransport-SendUploadRequestAsync>d__13`3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at SyncPro.Adapters.Dropbox.DropboxClient.<SendUploadFragment>d__49.MoveNext()
Sample Source Code:
public async Task SendUploadFragment(DropboxUploadSession uploadSession, byte[] fragmentBuffer, long offset)
{
for (int i = 1; i <= retry; i++)
{
try
{
teamclient = new DropboxApi.DropboxTeamClient(this.CurrentToken.RefreshToken, appkey, appsecret);
DropboxApi.DropboxClient clientadmin = teamclient.AsMember(this.UserProfile.TeamMemberId);
using (var memStream = new MemoryStream(fragmentBuffer, 0, fragmentBuffer.Length))
{
if (String.IsNullOrEmpty(uploadSession.SessionId))
{
if (!uploadSession.islastfragment)
{
UploadSessionStartArg args = new UploadSessionStartArg();
var result = await clientadmin.Files.UploadSessionStartAsync(args, memStream);
uploadSession.SessionId = result.SessionId;
}
else
{
FileMetadata fileMetadata = null;
try
{
fileMetadata = await clientadmin.Files.UploadAsync(new CommitInfo(uploadSession.Item.PathDisplay), memStream);
break;
}
catch (Exception ex)
{
if (ex is DropboxApi.RateLimitException)
{
Thread.Sleep(((DropboxApi.RateLimitException)ex).RetryAfter * 1000);
}
}
}
}
else
{
var cursor = new UploadSessionCursor(uploadSession.SessionId, (ulong)offset);
if (uploadSession.islastfragment)
{
FileMetadata fileMetadata = null;
try
{
fileMetadata = await clientadmin.Files.UploadSessionFinishAsync(cursor, new CommitInfo(uploadSession.Item.PathDisplay), memStream);
break;
}
catch (Exception ex)
{
if (ex is DropboxApi.RateLimitException)
{
Thread.Sleep(((DropboxApi.RateLimitException)ex).RetryAfter * 1000);
}
}
}
}
else
{
try
{
await clientadmin.Files.UploadSessionAppendV2Async(cursor, false, memStream);
break;
}
catch (Exception ex)
{
if (ex is DropboxApi.RateLimitException)
{
Thread.Sleep(((DropboxApi.RateLimitException)ex).RetryAfter * 1000);
}
}
}
}
}
break;
}
catch (Exception ex)
{
if (ex is DropboxApi.RateLimitException)
{
Thread.Sleep(((DropboxApi.RateLimitException)ex).RetryAfter * 1000);
}
if (i == retry)
{
throw ex;
}
}
}
}
Thanks,
Gagan