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)
|
internal static Shared.Models.ExifDirectory GetExifDirectory(Shared.Models.FilePath filePath, Shared.Models.DeterministicHashCode deterministicHashCode)
|
||||||
{
|
{
|
||||||
Shared.Models.ExifDirectory? result;
|
Shared.Models.ExifDirectory result;
|
||||||
System.Drawing.Size? size = Dimensions.GetDimensions(filePath.FullName);
|
System.Drawing.Size? size;
|
||||||
|
try
|
||||||
|
{ size = Dimensions.GetDimensions(filePath.FullName); }
|
||||||
|
catch (Exception)
|
||||||
|
{ size = null; }
|
||||||
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(filePath.FullName);
|
IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(filePath.FullName);
|
||||||
result = Covert(filePath, deterministicHashCode, size, directories);
|
result = Covert(filePath, deterministicHashCode, size, directories);
|
||||||
return result;
|
return result;
|
||||||
|
@ -10,6 +10,7 @@ public class RenameConfiguration
|
|||||||
public string? DefaultMaker { get; set; }
|
public string? DefaultMaker { get; set; }
|
||||||
public bool? ForceNewId { get; set; }
|
public bool? ForceNewId { get; set; }
|
||||||
public string[]? IgnoreExtensions { get; set; }
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public bool? OnlySaveIdentifiersToDisk { get; set; }
|
||||||
public string? RelativePropertyCollectionFile { get; set; }
|
public string? RelativePropertyCollectionFile { get; set; }
|
||||||
public string[]? SidecarExtensions { get; set; }
|
public string[]? SidecarExtensions { get; set; }
|
||||||
public bool? SkipIdFiles { 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.DefaultMaker is null) throw new NullReferenceException(nameof(configuration.DefaultMaker));
|
||||||
if (configuration.ForceNewId is null) throw new NullReferenceException(nameof(configuration.ForceNewId));
|
if (configuration.ForceNewId is null) throw new NullReferenceException(nameof(configuration.ForceNewId));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
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.RelativePropertyCollectionFile is null) throw new NullReferenceException(nameof(configuration.RelativePropertyCollectionFile));
|
||||||
if (configuration.SidecarExtensions is null) throw new NullReferenceException(nameof(configuration.SidecarExtensions));
|
if (configuration.SidecarExtensions is null) throw new NullReferenceException(nameof(configuration.SidecarExtensions));
|
||||||
if (configuration.SkipIdFiles is null) throw new NullReferenceException(nameof(configuration.SkipIdFiles));
|
if (configuration.SkipIdFiles is null) throw new NullReferenceException(nameof(configuration.SkipIdFiles));
|
||||||
@ -63,6 +65,7 @@ public class RenameConfiguration
|
|||||||
configuration.DefaultMaker,
|
configuration.DefaultMaker,
|
||||||
configuration.ForceNewId.Value,
|
configuration.ForceNewId.Value,
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
|
configuration.OnlySaveIdentifiersToDisk.Value,
|
||||||
configuration.RelativePropertyCollectionFile,
|
configuration.RelativePropertyCollectionFile,
|
||||||
configuration.SidecarExtensions,
|
configuration.SidecarExtensions,
|
||||||
configuration.SkipIdFiles.Value,
|
configuration.SkipIdFiles.Value,
|
||||||
|
@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace View_by_Distance.Rename.Models;
|
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()
|
public override string ToString()
|
||||||
|
@ -8,6 +8,7 @@ public record RenameConfiguration(Shared.Models.MetadataConfiguration MetadataCo
|
|||||||
string DefaultMaker,
|
string DefaultMaker,
|
||||||
bool ForceNewId,
|
bool ForceNewId,
|
||||||
string[] IgnoreExtensions,
|
string[] IgnoreExtensions,
|
||||||
|
bool OnlySaveIdentifiersToDisk,
|
||||||
string RelativePropertyCollectionFile,
|
string RelativePropertyCollectionFile,
|
||||||
string[] SidecarExtensions,
|
string[] SidecarExtensions,
|
||||||
bool SkipIdFiles,
|
bool SkipIdFiles,
|
||||||
|
@ -439,7 +439,7 @@ public partial class Rename : IRename, IDisposable
|
|||||||
if (record.ExifDirectory.Id is null)
|
if (record.ExifDirectory.Id is null)
|
||||||
continue;
|
continue;
|
||||||
paddedId = IId.GetPaddedId(renameConfiguration.MetadataConfiguration, record.ExifDirectory.Id.Value, record.FilePath.IsIgnore, index: null);
|
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);
|
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);
|
_ = 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);
|
logger?.LogInformation("{Ticks} {RootDirectory}", ticks, directoryInfo.FullName);
|
||||||
ReadOnlyCollection<RecordB> recordBCollection = GetRecordBCollection(rename, appSettings, renameConfiguration, directoryInfo);
|
ReadOnlyCollection<RecordB> recordBCollection = GetRecordBCollection(rename, appSettings, renameConfiguration, directoryInfo);
|
||||||
SaveIdentifiersToDisk(ticks, renameConfiguration, aMetadataCollectionDirectory, recordBCollection);
|
SaveIdentifiersToDisk(ticks, renameConfiguration, aMetadataCollectionDirectory, recordBCollection);
|
||||||
|
if (!renameConfiguration.OnlySaveIdentifiersToDisk)
|
||||||
|
{
|
||||||
ReadOnlyCollection<ToDo> toDoCollection = GetToDoCollection(renameConfiguration, identifiers, recordBCollection);
|
ReadOnlyCollection<ToDo> toDoCollection = GetToDoCollection(renameConfiguration, identifiers, recordBCollection);
|
||||||
ReadOnlyCollection<string> lines = RenameFilesInDirectories(toDoCollection);
|
ReadOnlyCollection<string> lines = RenameFilesInDirectories(toDoCollection);
|
||||||
if (lines.Count != 0)
|
if (lines.Count != 0)
|
||||||
@ -465,5 +467,6 @@ public partial class Rename : IRename, IDisposable
|
|||||||
_ = IPath.DeleteEmptyDirectories(directoryInfo.FullName);
|
_ = IPath.DeleteEmptyDirectories(directoryInfo.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user