Permalink
Browse files

RavenDB-5856 - continue to export files if on of the files failed to …

…export
  • Loading branch information...
1 parent 687de04 commit 16cae8c2cf4ad63f725ddcab528a52a98947b429 @grisha-kotler grisha-kotler committed with ayende Dec 18, 2016
Showing with 23 additions and 11 deletions.
  1. +23 −11 Raven.Abstractions/Smuggler/SmugglerFilesApiBase.cs
@@ -201,6 +201,8 @@ protected SmugglerFilesApiBase(SmugglerFilesOptions options)
try
{
+ var log = LogManager.GetCurrentClassLogger();
+
while (true)
{
FileHeader fileHeader = null;
@@ -216,23 +218,33 @@ protected SmugglerFilesApiBase(SmugglerFilesOptions options)
cts.Token.ThrowIfCancellationRequested();
- // Write the metadata (which includes the stream size and file container name)
- var fileContainer = new FileContainer
+ try
{
- Key = Path.Combine(fileHeader.Directory.TrimStart('/'), fileHeader.Name),
- Metadata = fileHeader.Metadata,
- };
+ // Write the metadata (which includes the stream size and file container name)
+ var fileContainer = new FileContainer
+ {
+ Key = Path.Combine(fileHeader.Directory.TrimStart('/'), fileHeader.Name),
+ Metadata = fileHeader.Metadata,
+ };
- ZipArchiveEntry fileToStore = archive.CreateEntry(fileContainer.Key);
+ ZipArchiveEntry fileToStore = archive.CreateEntry(fileContainer.Key);
- using (var fileStream = await Operations.DownloadFile(fileHeader).ConfigureAwait(false))
- using (var zipStream = fileToStore.Open())
+ using (var fileStream = await Operations.DownloadFile(fileHeader).ConfigureAwait(false))
+ using (var zipStream = fileToStore.Open())
+ {
+ await fileStream.CopyToAsync(zipStream).ConfigureAwait(false);
+ }
+
+ metadataList.Add(fileContainer);
+ }
+ catch (Exception e)
{
- await fileStream.CopyToAsync(zipStream).ConfigureAwait(false);
+ var message = $"Failed to export file: '{fileHeader.FullPath}', Exception: {e}, skipping it";
+ Operations.ShowProgress(message);
+ log.WarnException(message, e);
+ continue;
}
- metadataList.Add(fileContainer);
-
totalCount++;
if (totalCount % 30 == 0 || SystemTime.UtcNow - lastReport > reportInterval)
{

0 comments on commit 16cae8c

Please sign in to comment.