Skip to content

Commit

Permalink
Merge pull request #1015 from dmach/fix/1014-getbinaries-download-int…
Browse files Browse the repository at this point in the history
…o-subdirs

Fix getbinaries command by downloading files in subdirs named by the packages
  • Loading branch information
lethliel committed Apr 25, 2022
2 parents bc9869b + c9f8fed commit d5e04f8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
21 changes: 14 additions & 7 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7518,8 +7518,10 @@ def do_getbinaries(self, subcmd, opts, *args):


if package is None:
package_specified = False
package = meta_get_packagelist(apiurl, project, deleted=0)
else:
package_specified = True
if opts.multibuild_package:
packages = []
for subpackage in opts.multibuild_package:
Expand All @@ -7546,12 +7548,6 @@ def do_getbinaries(self, subcmd, opts, *args):
for i in binaries:
if binary != None and binary != i.name:
continue
# skip metadata (unless explicitly specified as the `FILE` (== `binary`) argument)
if not binary and i.name.startswith("_"):
continue
# skip logs (unless explicitly specified as the `FILE` (== `binary`) argument)
if not binary and i.name.endswith(".log"):
continue
# skip source rpms
if not opts.sources and (i.name.endswith('src.rpm') or i.name.endswith('sdeb')):
continue
Expand All @@ -7560,7 +7556,18 @@ def do_getbinaries(self, subcmd, opts, *args):
continue
if i.name.find('-debugsource-') >= 0:
continue
fname = '%s/%s' % (target_dir, i.name)

if package_specified:
# if package is specified, download everything into the target dir
fname = '%s/%s' % (target_dir, i.name)
elif i.name.startswith("_") or i.name.endswith(".log"):
# download logs and metadata into subdirs
# to avoid overwriting them with files with indentical names
fname = '%s/%s/%s' % (target_dir, pac, i.name)
else:
# always download packages into the target dir
fname = '%s/%s' % (target_dir, i.name)

if os.path.exists(fname):
st = os.stat(fname)
if st.st_mtime == i.mtime and st.st_size == i.size:
Expand Down
9 changes: 9 additions & 0 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4747,6 +4747,15 @@ def get_binary_file(apiurl, prj, repo, arch,

target_filename = target_filename or filename

# create target directory if it doesn't exist
target_dir = os.path.dirname(target_filename)
if target_dir:
try:
os.makedirs(target_dir, 0o755)
except OSError as e:
if e.errno != errno.EEXIST:
raise

where = package or '_repository'
u = makeurl(apiurl, ['build', prj, repo, arch, where, filename])
download(u, target_filename, progress_obj, target_mtime)
Expand Down

0 comments on commit d5e04f8

Please sign in to comment.