]> git.ipfire.org Git - pakfire.git/commitdiff
Fixes for removing files (and configfiles).
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Apr 2012 12:48:10 +0000 (14:48 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Apr 2012 12:48:10 +0000 (14:48 +0200)
There were some problems when the user removed those
files earlier.

python/pakfire/packages/base.py

index e27c3f77b2b8295d769d18c735e0490b38876ad7..91625362db70cdd3d02e7e521530c67771143569 100644 (file)
@@ -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)