mirror of
https://github.com/munki/munki.git
synced 2026-05-04 19:39:22 -05:00
Raise better exceptions/errors when a filepath given to makepkginfo doesn't exist or can't be read. Addresses #960.
This commit is contained in:
@@ -393,7 +393,11 @@ def makepkginfo(installeritem, options):
|
||||
|
||||
pkginfo = {}
|
||||
installs = []
|
||||
if installeritem and os.path.exists(installeritem):
|
||||
if installeritem:
|
||||
if not os.path.exists(installeritem):
|
||||
raise PkgInfoGenerationError(
|
||||
"File %s does not exist" % installeritem)
|
||||
|
||||
# Check if the item is a mount point for a disk image
|
||||
if dmgutils.pathIsVolumeMountPoint(installeritem):
|
||||
# Get the disk image path for the mount point
|
||||
@@ -405,7 +409,10 @@ def makepkginfo(installeritem, options):
|
||||
itemhash = "N/A"
|
||||
if os.path.isfile(installeritem):
|
||||
itemsize = int(os.path.getsize(installeritem))
|
||||
itemhash = munkihash.getsha256hash(installeritem)
|
||||
try:
|
||||
itemhash = munkihash.getsha256hash(installeritem)
|
||||
except OSError as err:
|
||||
raise PkgInfoGenerationError(err)
|
||||
|
||||
if pkgutils.hasValidDiskImageExt(installeritem):
|
||||
if dmgutils.DMGisWritable(installeritem) and options.print_warnings:
|
||||
|
||||
Reference in New Issue
Block a user