Skip to content

Commit

Permalink
Fix: enable transfer continuation if the failed content exists. (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
kavics authored Jun 13, 2023
1 parent ed3e0f2 commit 4b10345
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/SenseNet.IO/Implementations/RepositoryWriter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
Expand Down Expand Up @@ -244,7 +243,7 @@ await Retrier.RetryAsync(50, 3000, async () =>

resultString = await RESTCaller.GetResponseStringAsync(request, HttpMethod.Post, body, _repository.Server);
},
(i, exception) => exception.CheckRetryConditionOrThrow(i));
(i, exception) => exception.CheckRetryConditionOrThrow(i), cancel);

}
catch (ClientException e)
Expand All @@ -258,6 +257,16 @@ await Retrier.RetryAsync(50, 3000, async () =>
Messages = new[] {e.Message}
};
}
catch (Exception e)
{
_logger.LogError(e, $"Error during importing {repositoryPath}: {e.Message}.");
return new WriterState
{
WriterPath = repositoryPath,
Action = IsParentNotFoundException(repositoryPath, e) ? WriterAction.MissingParent : WriterAction.Failed,
Messages = new[] { e.Message }
};
}

// Upload binaries if there are.
var parentPath = ContentPath.GetParentPath(repositoryPath);
Expand Down Expand Up @@ -285,6 +294,18 @@ await _repository.UploadAsync(new UploadRequest
Messages = new[] { ex.Message }
};
}
catch (Exception e)
{
_logger.LogError(e, $"Error during {attachment.FieldName} attachment upload for {repositoryPath}: " +
$"{e.Message}.");

return new WriterState
{
WriterPath = repositoryPath,
Action = WriterAction.Failed,
Messages = new[] { e.Message }
};
}
}

// Process result
Expand Down

0 comments on commit 4b10345

Please sign in to comment.