Skip to content

Commit

Permalink
RavenDB-16815 - do todos 2
Browse files Browse the repository at this point in the history
  • Loading branch information
garayx committed Sep 18, 2024
1 parent 41069b3 commit 6a0fb68
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct BackupDestinationStream : IDisposable

public void Dispose()
{
BackupUploader?.Dispose();
BackupUploader?.Reset();
Stream?.Dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Raven.Client.Documents.Operations;
using Raven.Client.Documents.Operations.Backups;
using Raven.Client.Extensions;
using Raven.Client.Util;
using Raven.Server.Documents.PeriodicBackup.Aws;
using Raven.Server.Documents.PeriodicBackup.Azure;
using Raven.Server.Documents.PeriodicBackup.Retention;
Expand All @@ -17,7 +18,7 @@

namespace Raven.Server.Documents.PeriodicBackup.DirectUpload;

public sealed class DirectBackupUploader : BackupUploaderBase, IDisposable
public sealed class DirectBackupUploader : BackupUploaderBase
{
private readonly BackupConfiguration.BackupDestination _destination;

Expand Down Expand Up @@ -106,6 +107,7 @@ public void CreateUploadTask(DocumentDatabase database, Stream attachmentStream,

AddInfo($"Starting the upload of retired attachment '{objKeyName}'.");

using (attachmentStream)
using (var stream = StreamForBackupDestination(database, folderName, objKeyName))
attachmentStream.CopyTo(stream);

Expand Down Expand Up @@ -162,19 +164,18 @@ public bool TryCleanFinishedThreads(Stopwatch sp, OperationCancelToken token)
return false;
}


return true;
}

public void Dispose()
public IDisposable Initialize()
{
Execute();
_threads.Clear();
return new DisposableAction(Reset);
}

public void Reset()
{
Execute();
_threads.Clear();
}

}
Loading

0 comments on commit 6a0fb68

Please sign in to comment.