backend/satellite_tools/spacewalk-data-fsck | 14 +++----------- backend/satellite_tools/spacewalk-remove-channel | 18 ++---------------- backend/server/rhnPackage.py | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 27 deletions(-)
New commits: commit 0854c609096c9adc11f0969431652015c9e81759 Author: Simon Lukasik slukasik@redhat.com Date: Tue Aug 2 21:39:16 2011 +0200
extract method: unlink_package_file
diff --git a/backend/satellite_tools/spacewalk-data-fsck b/backend/satellite_tools/spacewalk-data-fsck index 032b645..3138dbd 100755 --- a/backend/satellite_tools/spacewalk-data-fsck +++ b/backend/satellite_tools/spacewalk-data-fsck @@ -12,6 +12,7 @@ try: from spacewalk.common.rhnLog import initLOG, log_debug from spacewalk.common.rhnConfig import CFG, initCFG from spacewalk.server import rhnSQL + from spacewalk.server.rhnPackage import unlink_package_file except: _LIBPATH = "/usr/share/rhn" # add to the path if need be @@ -19,6 +20,7 @@ except: sys.path.append(_LIBPATH) from common import CFG, initCFG, initLOG, log_debug from server import rhnSQL + from server.rhnPackage import unlink_package_file
LOG_FILE='/var/log/rhn/spacewalk-data-fsck.log'
@@ -213,17 +215,7 @@ def check_disk_vs_db(disk_content=None, db_content=None): def not_in_db(path, options): if options.remove: log(0, "Removed file missing in db: %s" % (path)) - os.unlink(path) - dirname = os.path.dirname(path) - while (dirname != CFG.MOUNT_POINT) and (dirname != CFG.MOUNT_POINT+'/'+CFG.PREPENDED_DIR): - try: - os.rmdir(dirname) - except OSError, e: - if e.errno == 39: #OSError: [Errno 39] Directory not empty - break - else: - raise e - dirname = os.path.dirname(dirname) + unlink_package_file(path) else: log(0, "File missing in db: %s" % (path))
diff --git a/backend/satellite_tools/spacewalk-remove-channel b/backend/satellite_tools/spacewalk-remove-channel index a126c9e..b5f6c69 100755 --- a/backend/satellite_tools/spacewalk-remove-channel +++ b/backend/satellite_tools/spacewalk-remove-channel @@ -32,6 +32,7 @@ from spacewalk.satellite_tools.progress_bar import ProgressBar from spacewalk.common.rhnLog import initLOG, log_debug, log_error from spacewalk.common.rhnConfig import CFG, initCFG from spacewalk.server import rhnSQL +from spacewalk.server.rhnPackage import unlink_package_file
options_table = [ Option("-v", "--verbose", action="count", @@ -516,22 +517,7 @@ def _delete_files(relpaths): if not os.path.exists(path): log_debug(1, "Not removing %s: no such file" % path) continue - try: - os.unlink(path) - except OSError: - log_debug(1, "Error unlinking %s;" % path) - - path = os.path.dirname(path) - base_dir = CFG.MOUNT_POINT + '/' + CFG.PREPENDED_DIR - while path != base_dir: - try: - os.rmdir(path) - except OSError, e: - if e.errno == 39: - break - else: - raise e - path = os.path.dirname(path) + unlink_package_file(path)
def _bind_many(l): h = {} diff --git a/backend/server/rhnPackage.py b/backend/server/rhnPackage.py index f4366d3..d375f6d 100644 --- a/backend/server/rhnPackage.py +++ b/backend/server/rhnPackage.py @@ -105,6 +105,22 @@ def check_package_file(rel_path, logpkg, raisepkg):
return filePath
+def unlink_package_file(path): + try: + os.unlink(path) + except OSError: + log_debug(1, "Error unlinking %s;" % path) + dirname = os.path.dirname(path) + base_dir = CFG.MOUNT_POINT + '/' + CFG.PREPENDED_DIR + while dirname != base_dir: + try: + os.rmdir(dirname) + except OSError, e: + if e.errno == 39: #OSError: [Errno 39] Directory not empty + break + else: + raise e + dirname = os.path.dirname(dirname)
# Old client # Get a package by [n,v,r,e] and compat arch