From: Michael Tremer Date: Sun, 22 Apr 2012 12:48:10 +0000 (+0200) Subject: Fixes for removing files (and configfiles). X-Git-Tag: 0.9.23~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d38612fe50395a35d6fdc0774d56c7c2ddc58cf7;p=pakfire.git Fixes for removing files (and configfiles). There were some problems when the user removed those files earlier. --- diff --git a/python/pakfire/packages/base.py b/python/pakfire/packages/base.py index e27c3f77b..91625362d 100644 --- a/python/pakfire/packages/base.py +++ b/python/pakfire/packages/base.py @@ -516,6 +516,12 @@ class Package(object): # Rename configuration files. if _file.is_config(): + # Skip already removed config files. + try: + os.lstat(file) + except OSError: + continue + file_save = "%s%s" % (file, CONFIG_FILE_SUFFIX_SAVE) try: @@ -530,6 +536,7 @@ class Package(object): # Handle regular files and symlinks. if os.path.isfile(file) or os.path.islink(file): + log.debug("Removing %s..." % _file) try: os.remove(file) except OSError: @@ -545,6 +552,11 @@ class Package(object): except OSError: pass + # Handle files that have already been removed + # by somebody else. + elif not os.path.exists(file): + pass + # Log all unhandled types. else: log.warning("Cannot remove file: %s. Filetype is unhandled." % file)