diff --git a/ComicNodes/Comics/CreateComicInfo.cs b/ComicNodes/Comics/CreateComicInfo.cs index 762cc288..e73bddbd 100644 --- a/ComicNodes/Comics/CreateComicInfo.cs +++ b/ComicNodes/Comics/CreateComicInfo.cs @@ -58,20 +58,6 @@ public class CreateComicInfo : Node var localFile = localFileResult.Value; - var result = args.ArchiveHelper.FileExists(localFile, "comicinfo.xml"); - if (result.Failed(out error)) - { - args.FailureReason = error; - args.Logger?.ELog(error); - return -1; - } - - if (result.Value) - { - args.Logger?.ILog("comicinfo.xml already present"); - return 2; - } - var infoResult = GetInfo(args.Logger, args.LibraryFileName, args.LibraryPath, Publisher); if (infoResult.Failed(out error)) { @@ -111,30 +97,49 @@ public class CreateComicInfo : Node } } - string xml = SerializeToXml(info); - if (string.IsNullOrWhiteSpace(xml)) - { - args.FailureReason = "Failed to serialize to XML"; - args.Logger?.ELog(args.FailureReason); - return -1; - } - args.Logger?.ILog("Created XML of ComicInfo"); - - string comicInfoFile = FileHelper.Combine(args.TempPath, "comicinfo.xml"); - args.Logger?.ILog("comicinfo.xml created: " + comicInfoFile); - File.WriteAllText(comicInfoFile, xml); - - if (args.ArchiveHelper.AddToArchive(localFile, comicInfoFile).Failed(out error)) + var result = args.ArchiveHelper.FileExists(localFile, "comicinfo.xml"); + if (result.Failed(out error)) { args.FailureReason = error; args.Logger?.ELog(error); return -1; } - args.Logger?.ILog("Added comicinfo.xml to archive"); - - if (localFile != args.WorkingFile && args.FileService.FileMove(localFile, args.WorkingFile).Failed(out error)) + + if (result.Value && RenameFile == false) { - args.Logger?.ELog("Failed to move saved file: " + error); + args.Logger?.ILog("comicinfo.xml already present"); + return 2; + } + + if (result.Value == false) + { + string xml = SerializeToXml(info); + if (string.IsNullOrWhiteSpace(xml)) + { + args.FailureReason = "Failed to serialize to XML"; + args.Logger?.ELog(args.FailureReason); + return -1; + } + + args.Logger?.ILog("Created XML of ComicInfo"); + + string comicInfoFile = FileHelper.Combine(args.TempPath, "comicinfo.xml"); + args.Logger?.ILog("comicinfo.xml created: " + comicInfoFile); + File.WriteAllText(comicInfoFile, xml); + + if (args.ArchiveHelper.AddToArchive(localFile, comicInfoFile).Failed(out error)) + { + args.FailureReason = error; + args.Logger?.ELog(error); + return -1; + } + + args.Logger?.ILog("Added comicinfo.xml to archive"); + if (localFile != args.WorkingFile && + args.FileService.FileMove(localFile, args.WorkingFile).Failed(out error)) + { + args.Logger?.ELog("Failed to move saved file: " + error); + } } if (RenameFile) diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll index d8888e4d..2a3d7411 100644 Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb index 6327aceb..7911b40e 100644 Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ