X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fpolicy.py;h=d4bd4a81c37c1a55b90fbde24c71b4926948167d;hb=9e40c7aa193ec9a3e4041369298167c9d0402fdf;hp=3a1cb32ca2ad0c7e4955549c6b8ea3c92ca9d84c;hpb=d0c59ca05415c09d05d5945f22cc3cd68363fe71;p=dak.git diff --git a/daklib/policy.py b/daklib/policy.py index 3a1cb32c..d4bd4a81 100644 --- a/daklib/policy.py +++ b/daklib/policy.py @@ -17,9 +17,10 @@ """module to process policy queue uploads""" from .config import Config -from .dbconn import BinaryMetadata, Component, MetadataKey, Override, OverrideType, get_mapped_component +from .dbconn import BinaryMetadata, Component, MetadataKey, Override, OverrideType, Suite, get_mapped_component from .fstransactions import FilesystemTransaction from .regexes import re_file_changes, re_file_safe +import daklib.utils as utils import errno import os @@ -48,7 +49,7 @@ class UploadCopy(object): self.directory = None self.upload = upload - def export(self, directory, mode=None, symlink=True): + def export(self, directory, mode=None, symlink=True, ignore_existing=False): """export a copy of the upload @type directory: str @@ -59,6 +60,9 @@ class UploadCopy(object): @type symlink: bool @param symlink: use symlinks instead of copying the files + + @type ignore_existing: bool + @param ignore_existing: ignore already existing files """ with FilesystemTransaction() as fs: source = self.upload.source @@ -68,22 +72,27 @@ class UploadCopy(object): for dsc_file in source.srcfiles: f = dsc_file.poolfile dst = os.path.join(directory, os.path.basename(f.filename)) - fs.copy(f.fullpath, dst, mode=mode, symlink=symlink) + if not os.path.exists(dst) or not ignore_existing: + fs.copy(f.fullpath, dst, mode=mode, symlink=symlink) + for binary in self.upload.binaries: f = binary.poolfile dst = os.path.join(directory, os.path.basename(f.filename)) - fs.copy(f.fullpath, dst, mode=mode, symlink=symlink) + if not os.path.exists(dst) or not ignore_existing: + fs.copy(f.fullpath, dst, mode=mode, symlink=symlink) # copy byhand files for byhand in self.upload.byhand: src = os.path.join(queue.path, byhand.filename) dst = os.path.join(directory, byhand.filename) - fs.copy(src, dst, mode=mode, symlink=symlink) + if not os.path.exists(dst) or not ignore_existing: + fs.copy(src, dst, mode=mode, symlink=symlink) # copy .changes src = os.path.join(queue.path, self.upload.changes.changesname) dst = os.path.join(directory, self.upload.changes.changesname) - fs.copy(src, dst, mode=mode, symlink=symlink) + if not os.path.exists(dst) or not ignore_existing: + fs.copy(src, dst, mode=mode, symlink=symlink) def __enter__(self): assert self.directory is None @@ -180,6 +189,8 @@ class PolicyQueueUploadHandler(object): @type reason: str @param reason: reason for the rejection """ + cnf = Config() + fn1 = 'REJECT.{0}'.format(self._changes_prefix) assert re_file_safe.match(fn1) @@ -187,6 +198,7 @@ class PolicyQueueUploadHandler(object): try: fh = os.open(fn, os.O_CREAT | os.O_EXCL | os.O_WRONLY) os.write(fh, 'NOTOK\n') + os.write(fh, 'From: {0} <{1}>\n\n'.format(utils.whoami(), cnf['Dinstall::MyAdminAddress'])) os.write(fh, reason) os.close(fh) except OSError as e: