mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-01-06 12:09:31 -06:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user