From 1013dd3c301a6be3fbd09b0a7944eef4b2765b63 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 2 Feb 2023 13:11:41 +0100 Subject: [PATCH] Jobs: Use TestFileSizeIsLessThanMaxFileSize --- Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb index 00fd4714..e14b4ec9 100644 --- a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -222,7 +222,7 @@ Public Class ImportZUGFeRDFiles oEmailAttachmentFiles.Add(oFile) ' Checking filesize for attachment files - If Check_FileSize(oFile, oArgs.MaxAttachmentSizeInMegaBytes) = False Then + If _filesystem.TestFileSizeIsLessThanMaxFileSize(oFile.FullName, oArgs.MaxAttachmentSizeInMegaBytes) = False Then _logger.Warn("Filesize for File [{0}] exceeded limit of {1} MB", oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) Throw New FileSizeLimitReachedException(oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) End If @@ -233,7 +233,7 @@ Public Class ImportZUGFeRDFiles _logger.Info("Start processing file {0}", oFile.Name) ' Checking filesize for pdf files - If Check_FileSize(oFile, oArgs.MaxAttachmentSizeInMegaBytes) = False Then + If _filesystem.TestFileSizeIsLessThanMaxFileSize(oFile.FullName, oArgs.MaxAttachmentSizeInMegaBytes) = False Then _logger.Warn("Filesize for File [{0}] exceeded limit of {1} MB", oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) Throw New FileSizeLimitReachedException(oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) End If @@ -844,30 +844,4 @@ Public Class ImportZUGFeRDFiles Return oMD5CheckSum End Function - - ''' - ''' Checks the size of the supplied file. - ''' - ''' - ''' - ''' - Private Function Check_FileSize(pFileInfo As FileInfo, pMaxFileSizeInMegaBytes As Integer) As Boolean - _logger.Info("Checking Filesize of {0}", pFileInfo.Name) - _logger.Debug("Filesize threshold is {0} MB.", pMaxFileSizeInMegaBytes) - - If pMaxFileSizeInMegaBytes <= 0 Then - _logger.Debug("Filesize is not configured. Skipping check.") - Return True - End If - - Dim oMaxSize = pMaxFileSizeInMegaBytes * 1024 * 1024 - - If oMaxSize > 0 And pFileInfo.Length > oMaxSize Then - _logger.Debug("Filesize is bigger than threshold. Rejecting.") - Return False - Else - _logger.Debug("Filesize is smaller than threshold. All fine.") - Return True - End If - End Function End Class