mirror of
https://github.com/munki/munki.git
synced 2026-01-06 06:29:56 -06:00
Better clean up of update cache
This commit is contained in:
@@ -125,15 +125,13 @@ class AppleUpdates(object):
|
||||
Returns:
|
||||
Boolean. True if successful, False otherwise.
|
||||
"""
|
||||
#msg = 'Downloading available Apple Software Updates...'
|
||||
msg = 'Checking for available Apple Software Updates...'
|
||||
self._ResetMunkiStatusAndDisplayMessage(msg)
|
||||
|
||||
if os.path.exists(INDEX_PLIST):
|
||||
# try to remove old/stale /Library/Updates/index.plist
|
||||
# in some older versions of OS X this can hang around
|
||||
# and is not always cleaned up when /usr/sbin/softwareupdate
|
||||
# finds no updates
|
||||
# try to remove old/stale /Library/Updates/index.plist --
|
||||
# in some older versions of OS X this can hang around and is not
|
||||
# always cleaned up when /usr/sbin/softwareupdate finds no updates
|
||||
try:
|
||||
os.unlink(INDEX_PLIST)
|
||||
except OSError:
|
||||
@@ -271,8 +269,7 @@ class AppleUpdates(object):
|
||||
'Skipping Apple Software Update check '
|
||||
'because sucatalog is unchanged, installed Apple packages are '
|
||||
'unchanged and we recently did a full check.')
|
||||
# return True if we have cached updates
|
||||
# False otherwise
|
||||
# return True if we have cached updates; False otherwise
|
||||
return bool(self.GetSoftwareUpdateInfo())
|
||||
|
||||
if self.DownloadAvailableUpdates(): # Success; ready to install.
|
||||
@@ -280,7 +277,7 @@ class AppleUpdates(object):
|
||||
product_ids = self.GetAvailableUpdateProductIDs()
|
||||
if not product_ids:
|
||||
# No updates found
|
||||
# TO-DO: clear metadata cache
|
||||
self.applesync.clean_up_cache()
|
||||
return False
|
||||
os_version_tuple = munkicommon.getOsVersion(as_tuple=True)
|
||||
if os_version_tuple < (10, 11):
|
||||
|
||||
@@ -321,8 +321,7 @@ class AppleUpdateSync(object):
|
||||
String path to the locally cached file.
|
||||
"""
|
||||
relative_url = os.path.normpath(self._GetURLPath(full_url).lstrip('/'))
|
||||
local_file_path = os.path.join(
|
||||
self.cache_dir, relative_url)
|
||||
local_file_path = os.path.join(self.cache_dir, relative_url)
|
||||
local_dir_path = os.path.dirname(local_file_path)
|
||||
if copy_only_if_missing and os.path.exists(local_file_path):
|
||||
return local_file_path
|
||||
@@ -367,12 +366,10 @@ class AppleUpdateSync(object):
|
||||
Distribution (.dist) files for the available updates to the local
|
||||
machine and writes a new sucatalog that refers to the local copies
|
||||
of these files."""
|
||||
catalog = FoundationPlist.readPlist(
|
||||
self.extracted_catalog_path)
|
||||
catalog = FoundationPlist.readPlist(self.extracted_catalog_path)
|
||||
if not 'Products' in catalog:
|
||||
display.display_warning(
|
||||
'"Products" not found in %s',
|
||||
self.extracted_catalog_path)
|
||||
'"Products" not found in %s', self.extracted_catalog_path)
|
||||
return
|
||||
|
||||
for product_key in product_ids:
|
||||
@@ -524,9 +521,10 @@ class AppleUpdateSync(object):
|
||||
|
||||
def clean_up_cache(self):
|
||||
"""Clean up our cache dir"""
|
||||
if os.path.exists(self.cache_dir):
|
||||
content_cache = os.path.join(self.cache_dir, 'content')
|
||||
if os.path.exists(content_cache):
|
||||
# TODO(unassigned): change this to Pythonic delete.
|
||||
dummy_retcode = subprocess.call(['/bin/rm', '-rf', self.cache_dir])
|
||||
dummy_retcode = subprocess.call(['/bin/rm', '-rf', content_cache])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user