diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index c9ece637..0c1d3292 100644 Binary files a/BasicNodes/BasicNodes.csproj and b/BasicNodes/BasicNodes.csproj differ diff --git a/BasicNodes/BasicNodes.en.json b/BasicNodes/BasicNodes.en.json index ed8275cf..d02974f9 100644 --- a/BasicNodes/BasicNodes.en.json +++ b/BasicNodes/BasicNodes.en.json @@ -121,6 +121,15 @@ "Upper-Help": "The value it must be less than than this number of megabytes. Leave as 0 to not test the upper limit." } }, + "FileSizeCompare": { + "Description": "Checks if the file size has changed sized from the original file. \n\nOutput 1: File is smaller than original\nOutput 2: File is same size\nOutput 3: File is larger than original", + "Outputs": { + "1": "Smaller than original", + "2": "Same size as original", + "3": "Larger than original" + } + + }, "Function": { "Outputs": { "1": "returned 1", diff --git a/BasicNodes/File/FileSizeCompare.cs b/BasicNodes/File/FileSizeCompare.cs new file mode 100644 index 00000000..2de83b33 --- /dev/null +++ b/BasicNodes/File/FileSizeCompare.cs @@ -0,0 +1,74 @@ +namespace FileFlows.BasicNodes.File +{ + using System.ComponentModel; + using FileFlows.Plugin; + using FileFlows.Plugin.Attributes; + + public class FileSizeCompare : Node + { + public override int Inputs => 1; + public override int Outputs => 3; + public override FlowElementType Type => FlowElementType.Logic; + public override string Icon => "fas fa-sitemap"; + + public override int Execute(NodeParameters args) + { + FileInfo fiOriginal = new FileInfo(args.FileName); + float origSize = 0; + if (fiOriginal.Exists == false) + { + // try get from variables + if (args.Variables.ContainsKey("file.Orig.Size") && args.Variables["file.Orig.Size"] is long tSize && tSize > 0) + { + origSize = tSize; + } + else + { + args.Logger?.ELog("Original file does not exists, cannot check size"); + return -1; + } + } + else + { + origSize = fiOriginal.Length; + } + + float wfSize = 0; + FileInfo fiWorkingFile = new FileInfo(args.WorkingFile); + if (fiWorkingFile.Exists == false) + { + if (args.WorkingFileSize > 0) + { + wfSize = args.WorkingFileSize; + } + else + { + args.Logger?.ELog("Working file does not exists, cannot check size"); + return -1; + } + } + else + { + wfSize = fiWorkingFile.Length; + } + + + args.Logger?.ILog("Original File Size: " + String.Format("{0:n0}", origSize)); + args.Logger?.ILog("Working File Size: " + String.Format("{0:n0}", wfSize)); + + + if (wfSize > origSize) + { + args.Logger?.ILog("Working file is larger than original"); + return 3; + } + if (origSize == wfSize) + { + args.Logger?.ILog("Working file is same size as the original"); + return 2; + } + args.Logger?.ILog("Working file is smaller than original"); + return 1; + } + } +} \ No newline at end of file diff --git a/BasicNodes/Tests/FileSizeCompareTests.cs b/BasicNodes/Tests/FileSizeCompareTests.cs new file mode 100644 index 00000000..614c9425 --- /dev/null +++ b/BasicNodes/Tests/FileSizeCompareTests.cs @@ -0,0 +1,115 @@ +#if(DEBUG) + +namespace BasicNodes.Tests +{ + using FileFlows.BasicNodes.File; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class FileSizeCompareTests + { + private string CreateFile(int size) + { + string tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + File.WriteAllText(tempFile, new string('a', size)); + return tempFile; + + } + [TestMethod] + public void FileSize_Shrunk() + { + string tempFile = CreateFile(2); + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(tempFile, logger, false, string.Empty); + + string wfFile = CreateFile(1); + args.SetWorkingFile(wfFile); + + FileSizeCompare node = new(); + int result = node.Execute(args); + Assert.AreEqual(1, result); + } + + [TestMethod] + public void FileSize_Grew() + { + string tempFile = CreateFile(2); + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(tempFile, logger, false, string.Empty); + + string wfFile = CreateFile(20); + args.SetWorkingFile(wfFile); + + FileSizeCompare node = new (); + int result = node.Execute(args); + Assert.AreEqual(3, result); + } + + [TestMethod] + public void FileSize_SameSize() + { + string tempFile = CreateFile(2); + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(tempFile, logger, false, string.Empty); + + string wfFile = CreateFile(2); + args.SetWorkingFile(wfFile); + + FileSizeCompare node = new(); + int result = node.Execute(args); + Assert.AreEqual(2, result); + } + + + [TestMethod] + public void FileSize_Shrunk_OriginalDeleted() + { + string tempFile = CreateFile(2); + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(tempFile, logger, false, string.Empty); + Assert.IsTrue(args.WorkingFileSize > 0); + File.Delete(tempFile); + + string wfFile = CreateFile(1); + args.SetWorkingFile(wfFile); + + FileSizeCompare node = new(); + int result = node.Execute(args); + Assert.AreEqual(1, result); + } + + [TestMethod] + public void FileSize_Grew_OriginalDeleted() + { + string tempFile = CreateFile(2); + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(tempFile, logger, false, string.Empty); + File.Delete(tempFile); + + string wfFile = CreateFile(20); + args.SetWorkingFile(wfFile); + + FileSizeCompare node = new(); + int result = node.Execute(args); + Assert.AreEqual(3, result); + } + + [TestMethod] + public void FileSize_SameSize_OriginalDeleted() + { + string tempFile = CreateFile(2); + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(tempFile, logger, false, string.Empty); + File.Delete(tempFile); + + string wfFile = CreateFile(2); + args.SetWorkingFile(wfFile); + + FileSizeCompare node = new(); + int result = node.Execute(args); + Assert.AreEqual(2, result); + } + } +} + +#endif \ No newline at end of file diff --git a/ChecksumNodes/ChecksumNodes.csproj b/ChecksumNodes/ChecksumNodes.csproj index e5577fa5..2afab6e7 100644 Binary files a/ChecksumNodes/ChecksumNodes.csproj and b/ChecksumNodes/ChecksumNodes.csproj differ diff --git a/CollectionNodes/CollectionNodes.csproj b/CollectionNodes/CollectionNodes.csproj index e11e6ab4..00f2657a 100644 Binary files a/CollectionNodes/CollectionNodes.csproj and b/CollectionNodes/CollectionNodes.csproj differ diff --git a/EmailNodes/EmailNodes.csproj b/EmailNodes/EmailNodes.csproj index 82889806..a60a12ba 100644 Binary files a/EmailNodes/EmailNodes.csproj and b/EmailNodes/EmailNodes.csproj differ diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll index a6073e53..c8557727 100644 Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb index f8687446..fafcc263 100644 Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index ac36980c..1927880c 100644 Binary files a/MetaNodes/MetaNodes.csproj and b/MetaNodes/MetaNodes.csproj differ diff --git a/MusicNodes/MusicNodes.csproj b/MusicNodes/MusicNodes.csproj index 3a4a0315..8a85e8fa 100644 Binary files a/MusicNodes/MusicNodes.csproj and b/MusicNodes/MusicNodes.csproj differ diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index 201b4f19..71cefbe5 100644 Binary files a/VideoNodes/VideoNodes.csproj and b/VideoNodes/VideoNodes.csproj differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll b/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll index 0a88c565..be6a1e6d 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll and b/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb b/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb index 851cf586..e488b5ac 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb and b/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll index 92c9de25..ba82ce4c 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll and b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb index 80370867..57d0a28c 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb and b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml index 1f393a83..c3138061 100644 --- a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml +++ b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml @@ -11,6 +11,13 @@ the string to clean the original string with all illegal characters removed + + + Calculates a fingerprint for a file + + The filename + The fingerprint + This class will allow hot reloading of an plugin assembly so they can be update diff --git a/build/utils/PluginInfoGenerator/FileFlows.Shared.dll b/build/utils/PluginInfoGenerator/FileFlows.Shared.dll index ab6a0461..1d4eeac0 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Shared.dll and b/build/utils/PluginInfoGenerator/FileFlows.Shared.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb b/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb index 8253ccee..d287b4f7 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb and b/build/utils/PluginInfoGenerator/FileFlows.Shared.pdb differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Shared.xml b/build/utils/PluginInfoGenerator/FileFlows.Shared.xml index 731dc1ea..b738373c 100644 --- a/build/utils/PluginInfoGenerator/FileFlows.Shared.xml +++ b/build/utils/PluginInfoGenerator/FileFlows.Shared.xml @@ -14,6 +14,11 @@ If this library monitors for folders or files + + + Gets or sets if this library will use fingerprinting to determine if a file already is known + + When the library was last scanned diff --git a/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll b/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll index 8eb22af0..9cc1365e 100644 Binary files a/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll and b/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll differ diff --git a/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb b/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb index b95a34a8..f82b355a 100644 Binary files a/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb and b/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb differ diff --git a/ref/FileFlows.Plugin.dll b/ref/FileFlows.Plugin.dll index 846cc403..aa9d61a4 100644 Binary files a/ref/FileFlows.Plugin.dll and b/ref/FileFlows.Plugin.dll differ