FF-346 - preserving last write time and attempting to preserve creation time of files if set (filesystem has to support these)

This commit is contained in:
John Andrews
2023-06-13 17:45:46 +12:00
parent ae59da110f
commit 53c637b037
9 changed files with 328 additions and 144 deletions

View File

@@ -61,6 +61,12 @@ namespace FileFlows.BasicNodes.File
[Boolean(5)]
public bool AdditionalFilesFromOriginal { get; set; }
/// <summary>
/// Gets or sets if the original files creation and last write time dates should be preserved
/// </summary>
[Boolean(6)]
public bool PreserverOriginalDates { get; set; }
private bool Canceled;
public override Task Cancel()
@@ -123,6 +129,15 @@ namespace FileFlows.BasicNodes.File
if (!copied)
return -1;
if(PreserverOriginalDates && args.Variables.TryGetValue("ORIGINAL_CREATE_UTC", out object oCreateTimeUtc) &&
args.Variables.TryGetValue("ORIGINAL_LAST_WRITE_UTC", out object oLastWriteUtc) &&
oCreateTimeUtc is DateTime dtCreateTimeUtc && oLastWriteUtc is DateTime dtLastWriteUtc)
{
Helpers.FileHelper.SetCreationTime(dest, dtCreateTimeUtc);
Helpers.FileHelper.SetLastWriteTime(dest, dtLastWriteUtc);
}
var srcDir = AdditionalFilesFromOriginal ? new FileInfo(args.MapPath(args.FileName)).DirectoryName : new FileInfo(args.MapPath(args.WorkingFile)).DirectoryName;
if (AdditionalFiles?.Any() == true)