diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb6fbf0..10cf3c6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ([!669](https://gitlab.com/fdroid/fdroidserver/merge_requests/669)) ### Fixed +* fix build-logs dissapearing when deploying + ([!685](https://gitlab.com/fdroid/fdroidserver/merge_requests/685)) * do not crash when system encoding can not be retrieved ([!671](https://gitlab.com/fdroid/fdroidserver/merge_requests/671)) * checkupdates: UpdateCheckIngore gets properly observed now diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 5429d924..e63320db 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -3253,6 +3253,9 @@ def deploy_build_log_with_rsync(appid, vercode, log_content): logging.warning(_('skip deploying full build logs: log content is empty')) return + if not os.path.exists('repo'): + os.mkdir('repo') + # gzip compress log file log_gz_path = os.path.join('repo', '{pkg}_{ver}.log.gz'.format(pkg=appid, diff --git a/tests/common.TestCase b/tests/common.TestCase index f99150ea..45e43f6f 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -1008,8 +1008,14 @@ class CommonTest(unittest.TestCase): with mock.patch('subprocess.call', side_effect=assert_subprocess_call): - fdroidserver.common.deploy_build_log_with_rsync( - 'com.example.app', '4711', mocklogcontent) + with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir): + fdroidserver.common.deploy_build_log_with_rsync( + 'com.example.app', '4711', mocklogcontent) + + expected_log_path = os.path.join(tmpdir, 'repo', 'com.example.app_4711.log.gz') + self.assertTrue(os.path.isfile(expected_log_path)) + with gzip.open(expected_log_path, 'r') as f: + self.assertEqual(f.read(), mocklogcontent) if __name__ == "__main__":