OnlySaveIdentifiersToDisk
This commit is contained in:
parent
30b8e2f5a9
commit
c838848129
@ -520,8 +520,12 @@ internal abstract class Exif
|
||||
|
||||
internal static Shared.Models.ExifDirectory GetExifDirectory(Shared.Models.FilePath filePath, Shared.Models.DeterministicHashCode deterministicHashCode)
|
||||
{
|
||||
Shared.Models.ExifDirectory? result;
|
||||
System.Drawing.Size? size = Dimensions.GetDimensions(filePath.FullName);
|
||||
Shared.Models.ExifDirectory result;
|
||||
System.Drawing.Size? size;
|
||||
try
|
||||
{ size = Dimensions.GetDimensions(filePath.FullName); }
|
||||
catch (Exception)
|
||||
{ size = null; }
|
||||
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(filePath.FullName);
|
||||
result = Covert(filePath, deterministicHashCode, size, directories);
|
||||
return result;
|
||||
|
@ -10,6 +10,7 @@ public class RenameConfiguration
|
||||
public string? DefaultMaker { get; set; }
|
||||
public bool? ForceNewId { get; set; }
|
||||
public string[]? IgnoreExtensions { get; set; }
|
||||
public bool? OnlySaveIdentifiersToDisk { get; set; }
|
||||
public string? RelativePropertyCollectionFile { get; set; }
|
||||
public string[]? SidecarExtensions { get; set; }
|
||||
public bool? SkipIdFiles { get; set; }
|
||||
@ -53,6 +54,7 @@ public class RenameConfiguration
|
||||
if (configuration.DefaultMaker is null) throw new NullReferenceException(nameof(configuration.DefaultMaker));
|
||||
if (configuration.ForceNewId is null) throw new NullReferenceException(nameof(configuration.ForceNewId));
|
||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
if (configuration.OnlySaveIdentifiersToDisk is null) throw new NullReferenceException(nameof(configuration.OnlySaveIdentifiersToDisk));
|
||||
if (configuration.RelativePropertyCollectionFile is null) throw new NullReferenceException(nameof(configuration.RelativePropertyCollectionFile));
|
||||
if (configuration.SidecarExtensions is null) throw new NullReferenceException(nameof(configuration.SidecarExtensions));
|
||||
if (configuration.SkipIdFiles is null) throw new NullReferenceException(nameof(configuration.SkipIdFiles));
|
||||
@ -63,6 +65,7 @@ public class RenameConfiguration
|
||||
configuration.DefaultMaker,
|
||||
configuration.ForceNewId.Value,
|
||||
configuration.IgnoreExtensions,
|
||||
configuration.OnlySaveIdentifiersToDisk.Value,
|
||||
configuration.RelativePropertyCollectionFile,
|
||||
configuration.SidecarExtensions,
|
||||
configuration.SkipIdFiles.Value,
|
||||
|
@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Rename.Models;
|
||||
|
||||
internal sealed record Identifier(int Id, string PaddedId)
|
||||
internal sealed record Identifier(int Id, long Length, string PaddedId, long Ticks)
|
||||
{
|
||||
|
||||
public override string ToString()
|
||||
|
@ -8,6 +8,7 @@ public record RenameConfiguration(Shared.Models.MetadataConfiguration MetadataCo
|
||||
string DefaultMaker,
|
||||
bool ForceNewId,
|
||||
string[] IgnoreExtensions,
|
||||
bool OnlySaveIdentifiersToDisk,
|
||||
string RelativePropertyCollectionFile,
|
||||
string[] SidecarExtensions,
|
||||
bool SkipIdFiles,
|
||||
|
@ -439,7 +439,7 @@ public partial class Rename : IRename, IDisposable
|
||||
if (record.ExifDirectory.Id is null)
|
||||
continue;
|
||||
paddedId = IId.GetPaddedId(renameConfiguration.MetadataConfiguration, record.ExifDirectory.Id.Value, record.FilePath.IsIgnore, index: null);
|
||||
identifiers.Add(new(record.ExifDirectory.Id.Value, paddedId));
|
||||
identifiers.Add(new(record.ExifDirectory.Id.Value, record.FilePath.Length, paddedId, record.DateTime.Ticks));
|
||||
}
|
||||
string json = JsonSerializer.Serialize(identifiers.OrderBy(l => l.PaddedId).ToArray(), IdentifierCollectionSourceGenerationContext.Default.IdentifierArray);
|
||||
_ = IPath.WriteAllText(Path.Combine(aMetadataCollectionDirectory, $"{ticks}.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||
@ -457,6 +457,8 @@ public partial class Rename : IRename, IDisposable
|
||||
logger?.LogInformation("{Ticks} {RootDirectory}", ticks, directoryInfo.FullName);
|
||||
ReadOnlyCollection<RecordB> recordBCollection = GetRecordBCollection(rename, appSettings, renameConfiguration, directoryInfo);
|
||||
SaveIdentifiersToDisk(ticks, renameConfiguration, aMetadataCollectionDirectory, recordBCollection);
|
||||
if (!renameConfiguration.OnlySaveIdentifiersToDisk)
|
||||
{
|
||||
ReadOnlyCollection<ToDo> toDoCollection = GetToDoCollection(renameConfiguration, identifiers, recordBCollection);
|
||||
ReadOnlyCollection<string> lines = RenameFilesInDirectories(toDoCollection);
|
||||
if (lines.Count != 0)
|
||||
@ -465,5 +467,6 @@ public partial class Rename : IRename, IDisposable
|
||||
_ = IPath.DeleteEmptyDirectories(directoryInfo.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user