summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-25 16:21:39 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-25 16:21:39 -0400
commitef8aad0268ae9dc9efebd96714ca23e5a5369b49 (patch)
treefec90cb3e5ef14419f6eaed374d6192ea02fc783 /modules
parent637c6db316c12384f89825e12bf47dda7609ebb9 (diff)
parent8a2e2059faecc3b4c4b11363d6fd620ec0535bed (diff)
downloadthird_party-func-ef8aad0268ae9dc9efebd96714ca23e5a5369b49.tar.gz
third_party-func-ef8aad0268ae9dc9efebd96714ca23e5a5369b49.tar.xz
third_party-func-ef8aad0268ae9dc9efebd96714ca23e5a5369b49.zip
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
Diffstat (limited to 'modules')
-rw-r--r--modules/copyfile.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/copyfile.py b/modules/copyfile.py
index 7d04abf..58b5ea4 100644
--- a/modules/copyfile.py
+++ b/modules/copyfile.py
@@ -47,10 +47,13 @@ class CopyFile(func_module.FuncModule):
return thissum.hexdigest()
- def copyfile(self, filepath, filebuf):
+ def copyfile(self, filepath, filebuf, mode=0644, uid=0, gid=0, force=None):
# -1 = problem file was not copied
# 1 = file was copied
# 0 = file was not copied b/c file is unchanged
+
+
+ # we should probably verify mode,uid,gid are valid as well
dirpath = os.path.dirname(filepath)
basepath = os.path.basename(filepath)
@@ -62,7 +65,7 @@ class CopyFile(func_module.FuncModule):
if os.path.exists(filepath):
local_sum = self.checksum(filepath)
- if remote_sum != local_sum:
+ if remote_sum != local_sum or force is not None:
# back up the localone
if os.path.exists(filepath):
if not self._backuplocal(filepath):
@@ -79,6 +82,14 @@ class CopyFile(func_module.FuncModule):
return -1
else:
return 0
+
+ # hmm, need to figure out proper exceptions -akl
+ try:
+ # we could intify the mode here if it's a string
+ os.chmod(filepath, mode)
+ os.chown(filepath, uid, gid)
+ except (IOError, OSError), e:
+ return -1
return 1