]>
Commit | Line | Data |
---|---|---|
e38af838 MT |
1 | From d38612fe50395a35d6fdc0774d56c7c2ddc58cf7 Mon Sep 17 00:00:00 2001 |
2 | From: Michael Tremer <michael.tremer@ipfire.org> | |
3 | Date: Sun, 22 Apr 2012 14:48:10 +0200 | |
d72d822f | 4 | Subject: [PATCH 08/16] Fixes for removing files (and configfiles). |
e38af838 MT |
5 | |
6 | There were some problems when the user removed those | |
7 | files earlier. | |
8 | --- | |
9 | python/pakfire/packages/base.py | 12 ++++++++++++ | |
d72d822f | 10 | 1 file changed, 12 insertions(+) |
e38af838 MT |
11 | |
12 | diff --git a/python/pakfire/packages/base.py b/python/pakfire/packages/base.py | |
13 | index e27c3f7..9162536 100644 | |
14 | --- a/python/pakfire/packages/base.py | |
15 | +++ b/python/pakfire/packages/base.py | |
16 | @@ -516,6 +516,12 @@ class Package(object): | |
17 | ||
18 | # Rename configuration files. | |
19 | if _file.is_config(): | |
20 | + # Skip already removed config files. | |
21 | + try: | |
22 | + os.lstat(file) | |
23 | + except OSError: | |
24 | + continue | |
25 | + | |
26 | file_save = "%s%s" % (file, CONFIG_FILE_SUFFIX_SAVE) | |
27 | ||
28 | try: | |
29 | @@ -530,6 +536,7 @@ class Package(object): | |
30 | ||
31 | # Handle regular files and symlinks. | |
32 | if os.path.isfile(file) or os.path.islink(file): | |
33 | + log.debug("Removing %s..." % _file) | |
34 | try: | |
35 | os.remove(file) | |
36 | except OSError: | |
37 | @@ -545,6 +552,11 @@ class Package(object): | |
38 | except OSError: | |
39 | pass | |
40 | ||
41 | + # Handle files that have already been removed | |
42 | + # by somebody else. | |
43 | + elif not os.path.exists(file): | |
44 | + pass | |
45 | + | |
46 | # Log all unhandled types. | |
47 | else: | |
48 | log.warning("Cannot remove file: %s. Filetype is unhandled." % file) | |
49 | -- | |
d72d822f | 50 | 1.7.10.4 |
e38af838 | 51 |