From d6651068136d5bf54908fb49aea94764885e187e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Tue, 15 Oct 2019 14:28:45 +0200 Subject: [PATCH] fix disappearing build logs when deploying --- fdroidserver/common.py | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 059a641f..5429d924 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -3253,42 +3253,41 @@ def deploy_build_log_with_rsync(appid, vercode, log_content): logging.warning(_('skip deploying full build logs: log content is empty')) return - with tempfile.TemporaryDirectory() as tmpdir: - # gzip compress log file - log_gz_path = os.path.join( - tmpdir, '{pkg}_{ver}.log.gz'.format(pkg=appid, - ver=vercode)) - with gzip.open(log_gz_path, 'wb') as f: - if isinstance(log_content, str): - f.write(bytes(log_content, 'utf-8')) - else: - f.write(log_content) + # gzip compress log file + log_gz_path = os.path.join('repo', + '{pkg}_{ver}.log.gz'.format(pkg=appid, + ver=vercode)) + with gzip.open(log_gz_path, 'wb') as f: + if isinstance(log_content, str): + f.write(bytes(log_content, 'utf-8')) + else: + f.write(log_content) - # TODO: sign compressed log file, if a signing key is configured + # TODO: sign compressed log file, if a signing key is configured - for webroot in config.get('serverwebroot', []): - dest_path = os.path.join(webroot, "repo") - if not dest_path.endswith('/'): - dest_path += '/' # make sure rsync knows this is a directory - cmd = ['rsync', - '--archive', - '--delete-after', - '--safe-links'] - if options.verbose: - cmd += ['--verbose'] - if options.quiet: - cmd += ['--quiet'] - if 'identity_file' in config: - cmd += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + config['identity_file']] - cmd += [log_gz_path, dest_path] + for webroot in config.get('serverwebroot', []): + dest_path = os.path.join(webroot, "repo") + if not dest_path.endswith('/'): + dest_path += '/' # make sure rsync knows this is a directory + cmd = ['rsync', + '--archive', + '--delete-after', + '--safe-links'] + if options.verbose: + cmd += ['--verbose'] + if options.quiet: + cmd += ['--quiet'] + if 'identity_file' in config: + cmd += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + config['identity_file']] + cmd += [log_gz_path, dest_path] - # TODO: also deploy signature file if present + # TODO: also deploy signature file if present - retcode = subprocess.call(cmd) - if retcode: - logging.warning(_("failed deploying build logs to '{path}'").format(path=webroot)) - else: - logging.info(_("deployed build logs to '{path}'").format(path=webroot)) + retcode = subprocess.call(cmd) + if retcode: + logging.warning(_("failed deploying build logs to '{path}'").format(path=webroot)) + else: + logging.info(_("deployed build logs to '{path}'").format(path=webroot)) def get_per_app_repos(): @@ -3321,6 +3320,7 @@ def is_repo_file(filename): return os.path.isfile(filename) \ and not filename.endswith(b'.asc') \ and not filename.endswith(b'.sig') \ + and not filename.endswith(b'.log.gz') \ and os.path.basename(filename) not in [ b'index.jar', b'index_unsigned.jar',