From 9a545d36dc0b1bf1ebcad229c484dee3b480425e Mon Sep 17 00:00:00 2001 From: root Date: Tue, 24 Jan 2012 09:19:30 +0000 Subject: Use shutil instead of os to push packages --- backend/server/importlib/importLib.py | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/backend/server/importlib/importLib.py b/backend/server/importlib/importLib.py index 3572ed0..58957a8 100644 --- a/backend/server/importlib/importLib.py +++ b/backend/server/importlib/importLib.py @@ -17,12 +17,14 @@ # import os +import shutil from types import IntType, StringType, InstanceType from UserDict import UserDict from UserList import UserList from spacewalk.common.checksum import getFileChecksum from spacewalk.common.fileutils import createPath, setPermsPath +from spacewalk.common.rhnConfig import CFG # no-op class, used to define the type of an attribute class DateType: @@ -808,7 +810,15 @@ def move_package(filename, basedir, relpath, checksum_type, checksum, force=None # Create the directory where the file will reside if not os.path.exists(dir): createPath(dir) - os.rename(filename, packagePath) + + # Check if the RPM has been downloaded from a remote repository + # If so, it is stored in CFG.MOUNT_POINT and we have to move it + # If not, the repository is local to the server, so the rpm should be copied + if filename.startswith(CFG.MOUNT_POINT): + shutil.move(filename, packagePath) + else: + shutil.copy(filename, packagePath) + # set the path perms readable by all users os.chmod(packagePath, 0644) -- 1.7.4.1