Skip to content

Commit

Permalink
#1833 revert this
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Jan 24, 2025
1 parent 3f908f4 commit fe8709c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions starsky/starsky.foundation.writemeta/Helpers/ExifTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public sealed class ExifTool : IExifTool
private readonly AppSettings _appSettings;
private readonly IStorage _iStorage;
private readonly IWebLogger _logger;
private readonly ExifToolStreamToStreamRunner _runner;
private readonly IStorage _thumbnailStorage;

public ExifTool(IStorage sourceStorage, IStorage thumbnailStorage, AppSettings appSettings,
Expand All @@ -33,7 +32,6 @@ public ExifTool(IStorage sourceStorage, IStorage thumbnailStorage, AppSettings a
_iStorage = sourceStorage;
_thumbnailStorage = thumbnailStorage;
_logger = logger;
_runner = new ExifToolStreamToStreamRunner(_appSettings, _logger);
}

/// <summary>
Expand Down Expand Up @@ -63,13 +61,14 @@ public async Task<bool> WriteTagsAsync(string subPath, string command)
_logger.LogInformation($"[WriteTagsAsync] Next update for {subPath}");

var inputStream = _iStorage.ReadStream(subPath);
var stream = await _runner.RunProcessAsync(inputStream, command, subPath);

var runner = new ExifToolStreamToStreamRunner(_appSettings, _logger);
var stream = await runner.RunProcessAsync(inputStream, command, subPath);

// Need to Dispose for Windows
// inputStream is disposed
await inputStream.DisposeAsync();

// stream is disposed in writeStreamAsync
return await _iStorage.WriteStreamAsync(stream, subPath);
}

Expand All @@ -82,8 +81,8 @@ public async Task<bool> WriteTagsAsync(string subPath, string command)
public async Task<bool> WriteTagsThumbnailAsync(string fileHash, string command)
{
var inputStream = _thumbnailStorage.ReadStream(fileHash);
var stream = await _runner.RunProcessAsync(inputStream,
command, fileHash);
var runner = new ExifToolStreamToStreamRunner(_appSettings, _logger);
var stream = await runner.RunProcessAsync(inputStream, command, fileHash);
// Need to Close/Dispose for Windows and needs before WriteStreamAsync
await inputStream.DisposeAsync();
return await _thumbnailStorage.WriteStreamAsync(stream, fileHash);
Expand All @@ -102,7 +101,8 @@ private async Task<KeyValuePair<bool, string>>
beforeFileHash ??= await FileHash.CalculateHashAsync(sourceStream,
false, cancellationToken);

var stream = await _runner.RunProcessAsync(sourceStream, command, subPath);
var runner = new ExifToolStreamToStreamRunner(_appSettings, _logger);
var stream = await runner.RunProcessAsync(sourceStream, command, subPath);

// Need to Close / Dispose for Windows
sourceStream.Close();
Expand Down

0 comments on commit fe8709c

Please sign in to comment.