Commit 2f899dfb authored by thomas.forbriger's avatar thomas.forbriger Committed by Checksum Backup @bromo

csfile.py: capture error in case of illegal hash type

parent 8e0b087e
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
# the end time # the end time
# 01/08/2019 V0.6.6 (thof) let getSubDirectories produce a reasonable error # 01/08/2019 V0.6.6 (thof) let getSubDirectories produce a reasonable error
# message, if application of a regex fails # message, if application of a regex fails
# V0.6.7 (thof) capture problem with whitespace in file names
# which results in not accepted hash types
# #
# ============================================================================= # =============================================================================
""" CsFile module to handle checksumfiles. """ """ CsFile module to handle checksumfiles. """
...@@ -70,7 +72,7 @@ from datetime import date ...@@ -70,7 +72,7 @@ from datetime import date
import csbacklog import csbacklog
import csbackErrorCodes as eCodes import csbackErrorCodes as eCodes
__version__ = "V0.6.6" __version__ = "V0.6.7"
__subversion__ = "$Id$" __subversion__ = "$Id$"
__license__ = "GPLv2+" __license__ = "GPLv2+"
__author__ = "Daniel Armbruster" __author__ = "Daniel Armbruster"
...@@ -495,7 +497,14 @@ class CsLine: ...@@ -495,7 +497,14 @@ class CsLine:
located in src. In case no data file was found in src an CsFileError located in src. In case no data file was found in src an CsFileError
exception will be thrown. exception will be thrown.
""" """
hashfunc = hashlib.new(self.hashfunc) try:
hashfunc = hashlib.new(self.hashfunc)
except:
raise CsFileError(("When evaluating checksum file entry\n in directory %s\n"
+" hash type '%s' as specified for file '%s' is not accepted\n"
+" consider a problem with whitespace in file names\n"
+" the respective checksum file entry is\n"
+" %s") % (self.srcdir, self.hashfunc, self.filename, self), eCodes.GLOBAL_UnhandledException)
blockSize = chunkSize * hashfunc.block_size blockSize = chunkSize * hashfunc.block_size
path = os.path.join(self.srcdir, self.filename) path = os.path.join(self.srcdir, self.filename)
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment