1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-21 04:10:37 +02:00

refactor: revert changes to the full sync mode for s3cmd

This commit is contained in:
proletarius101 2023-12-14 15:18:23 +00:00
parent 1cf0185508
commit 2c361f6cee
No known key found for this signature in database

View File

@ -185,43 +185,49 @@ def update_awsbucket_s3cmd(repo_section):
path=repo_section, url=s3url path=repo_section, url=s3url
) )
) )
if not options.index_only:
logging.debug('s3cmd syncs new non-index files in ' + repo_section + ' to ' + s3url + 'and deletes removed') if options.index_only:
logging.debug(_('s3cmd syncs indexes from {path} to {url} and deletes removed')
.format(path=repo_section, url=s3url))
sync_indexes_flags = []
sync_indexes_flags.append('--delete-removed')
sync_indexes_flags.append('--delete-after')
if options.no_checksum:
sync_indexes_flags.append('--no-check-md5')
else:
sync_indexes_flags.append('--check-md5')
sync_indexes_flags.extend(_get_index_includes(repo_section))
returncode = subprocess.call(s3cmd_sync + sync_indexes_flags + [repo_section, s3url])
if returncode != 0:
raise FDroidException()
else:
logging.debug('s3cmd sync new files in ' + repo_section + ' to ' + s3url)
logging.debug(_('Running first pass with MD5 checking disabled')) logging.debug(_('Running first pass with MD5 checking disabled'))
sync_non_indexes_flags = [] excludes = _get_index_excludes(repo_section)
# Excluded files are not considered as removed: https://github.com/s3tools/s3cmd/issues/802
sync_non_indexes_flags.append('--delete-removed')
sync_non_indexes_flags.append('--delete-after')
sync_non_indexes_flags.extend(_get_index_excludes(repo_section))
returncode = subprocess.call( returncode = subprocess.call(
s3cmd_sync s3cmd_sync
+ sync_non_indexes_flags + excludes
+ ['--no-check-md5', '--skip-existing', repo_section, s3url] + ['--no-check-md5', '--skip-existing', repo_section, s3url]
) )
if returncode != 0: if returncode != 0:
raise FDroidException() raise FDroidException()
logging.debug('s3cmd sync all files in ' + repo_section + ' to ' + s3url) logging.debug('s3cmd sync all files in ' + repo_section + ' to ' + s3url)
returncode = subprocess.call( returncode = subprocess.call(
s3cmd_sync + sync_non_indexes_flags + ['--no-check-md5', repo_section, s3url] s3cmd_sync + excludes + ['--no-check-md5', repo_section, s3url]
) )
if returncode != 0: if returncode != 0:
raise FDroidException() raise FDroidException()
logging.debug(_('s3cmd syncs indexes from {path} to {url} and deletes removed') logging.debug(_('s3cmd sync indexes {path} to {url} and delete')
.format(path=repo_section, url=s3url)) .format(path=repo_section, url=s3url))
sync_indexes_flags = [] s3cmd_sync.append('--delete-removed')
sync_indexes_flags.append('--delete-removed') s3cmd_sync.append('--delete-after')
sync_indexes_flags.append('--delete-after') if options.no_checksum:
if options.no_checksum: s3cmd_sync.append('--no-check-md5')
sync_indexes_flags.append('--no-check-md5') else:
else: s3cmd_sync.append('--check-md5')
sync_indexes_flags.append('--check-md5') if subprocess.call(s3cmd_sync + [repo_section, s3url]) != 0:
sync_indexes_flags.extend(_get_index_includes(repo_section)) raise FDroidException()
returncode = subprocess.call(s3cmd_sync + sync_indexes_flags + [repo_section, s3url])
if returncode != 0:
raise FDroidException()
def update_remote_storage_with_rclone(repo_section, verbose=False, quiet=False): def update_remote_storage_with_rclone(repo_section, verbose=False, quiet=False):