mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-21 12:49:43 +03:00
Remove UnownedFileStorage type and move the logic to the call site
This commit is contained in:
parent
5a8176bb46
commit
53f5ed9a04
@ -215,7 +215,6 @@ namespace NAPS2.Images.Storage
|
||||
RegisterTransformers<GdiImage>(new GdiTransformers());
|
||||
ImageType = typeof(GdiImage);
|
||||
// TODO: Not sure where to do these
|
||||
RegisterConverters(new OwnershipConverters(this));
|
||||
RegisterConverters(new PdfConverters(this));
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace NAPS2.Images.Storage
|
||||
{
|
||||
public class OwnershipConverters
|
||||
{
|
||||
private readonly ImageContext imageContext;
|
||||
|
||||
public OwnershipConverters(ImageContext imageContext)
|
||||
{
|
||||
this.imageContext = imageContext;
|
||||
}
|
||||
|
||||
[StorageConverter]
|
||||
public FileStorage ConvertToFile(UnownedFileStorage input, StorageConvertParams convertParams)
|
||||
{
|
||||
string newPath = imageContext.FileStorageManager.NextFilePath();
|
||||
File.Copy(input.FilePath, newPath);
|
||||
return new FileStorage(newPath);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace NAPS2.Images.Storage
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an image received across the wire where we must copy the backing
|
||||
/// file before it can be used.
|
||||
/// </summary>
|
||||
public class UnownedFileStorage : IStorage
|
||||
{
|
||||
public UnownedFileStorage(string filePath)
|
||||
{
|
||||
FilePath = filePath ?? throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
|
||||
public string FilePath { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -188,9 +188,7 @@
|
||||
<Compile Include="Images\MemoryStreamRenderer.cs" />
|
||||
<Compile Include="Images\ScannedImageSink.cs" />
|
||||
<Compile Include="Images\Storage\LockMode.cs" />
|
||||
<Compile Include="Images\Storage\OwnershipConverters.cs" />
|
||||
<Compile Include="Images\Storage\PdfConverters.cs" />
|
||||
<Compile Include="Images\Storage\UnownedFileStorage.cs" />
|
||||
<Compile Include="Images\Storage\PdfStorage.cs" />
|
||||
<Compile Include="ImportExport\DirectImportParams.cs" />
|
||||
<Compile Include="ImportExport\Email\Mapi\IMapiWrapper.cs" />
|
||||
|
@ -68,8 +68,10 @@ namespace NAPS2.Serialization
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: With this logic centralized, maybe we can remove UnownedFileStorage and just move the file copy logic here?
|
||||
storage = new UnownedFileStorage(serializedImage.FilePath);
|
||||
// Not transfering or sharing the file, so we need to make a copy
|
||||
string newPath = imageContext.FileStorageManager.NextFilePath();
|
||||
File.Copy(serializedImage.FilePath, newPath);
|
||||
storage = new FileStorage(newPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user