Add 'repo.json' to url before giving it to bpkg
This commit is contained in:
@@ -37,6 +37,7 @@ if 'bpy' in locals():
|
||||
else:
|
||||
from . import subproc
|
||||
from . import bpkg
|
||||
from . import utils
|
||||
from .bpkg import Package
|
||||
|
||||
import bpy
|
||||
@@ -389,6 +390,7 @@ class PACKAGE_OT_refresh_repositories(SubprocMixin, bpy.types.Operator):
|
||||
|
||||
def cancel(self, context):
|
||||
PACKAGE_OT_refresh_repositories._running = False
|
||||
context.area.tag_redraw()
|
||||
|
||||
def create_subprocess(self):
|
||||
"""Starts the download process.
|
||||
@@ -442,7 +444,6 @@ class PACKAGE_OT_refresh_repositories(SubprocMixin, bpy.types.Operator):
|
||||
pkg.repository = result.repository.name
|
||||
|
||||
_packages = build_composite_packagelist(installed_packages, available_packages)
|
||||
USERPREF_PT_packages.available_packages = available_packages
|
||||
self.report({'INFO'}, 'Package list retrieved successfully')
|
||||
|
||||
def _subproc_aborted(self, aborted: subproc.Aborted):
|
||||
@@ -548,13 +549,6 @@ class PACKAGE_UL_repositories(bpy.types.UIList):
|
||||
else:
|
||||
layout.label(item.name)
|
||||
|
||||
def parse_repository_url(url: str) -> str:
|
||||
"""Sanitize repository url"""
|
||||
from urllib.parse import urlsplit, urlunsplit
|
||||
parsed_url = urlsplit(url)
|
||||
new_path = parsed_url.path.rstrip("repo.json")
|
||||
return urlunsplit((parsed_url.scheme, parsed_url.netloc, new_path, parsed_url.query, parsed_url.fragment))
|
||||
|
||||
class PACKAGE_OT_add_repository(bpy.types.Operator):
|
||||
bl_idname = "package.add_repository"
|
||||
bl_label = "Add Repository"
|
||||
@@ -576,7 +570,7 @@ class PACKAGE_OT_add_repository(bpy.types.Operator):
|
||||
return {'CANCELLED'}
|
||||
|
||||
repo = prefs.repositories.add()
|
||||
repo.url = parse_repository_url(self.url)
|
||||
repo.url = utils.parse_repository_url(self.url)
|
||||
|
||||
context.area.tag_redraw()
|
||||
return {'FINISHED'}
|
||||
|
@@ -2,6 +2,7 @@ import logging
|
||||
import json
|
||||
from pathlib import Path
|
||||
from . import exceptions
|
||||
from . import utils
|
||||
|
||||
class Package:
|
||||
"""
|
||||
|
@@ -6,7 +6,8 @@ import logging
|
||||
import pathlib
|
||||
import shutil
|
||||
import json
|
||||
from .bpkg import utils
|
||||
from . import utils
|
||||
from . import bpkg
|
||||
from .bpkg import Package, Repository
|
||||
from .messages import *
|
||||
from .bpkg.exceptions import *
|
||||
@@ -135,7 +136,7 @@ def _install(pipe_to_blender, pkgpath: pathlib.Path, dest: pathlib.Path, searchp
|
||||
backups = []
|
||||
for conflict in conflicts:
|
||||
log.debug("Creating backup of conflict %s", conflict)
|
||||
backups.append(utils.InplaceBackup(conflict))
|
||||
backups.append(bpkg.utils.InplaceBackup(conflict))
|
||||
|
||||
try:
|
||||
file_to_extract.extractall(str(dest))
|
||||
@@ -152,7 +153,7 @@ def _install(pipe_to_blender, pkgpath: pathlib.Path, dest: pathlib.Path, searchp
|
||||
dest_file = (dest / pkgpath.name)
|
||||
|
||||
if dest_file.exists():
|
||||
backup = utils.InplaceBackup(dest_file)
|
||||
backup = bpkg.utils.InplaceBackup(dest_file)
|
||||
|
||||
try:
|
||||
shutil.copyfile(str(pkgpath), str(dest_file))
|
||||
@@ -226,6 +227,7 @@ def refresh(pipe_to_blender, storage_path: pathlib.Path, repository_url: str):
|
||||
"""Retrieves and stores the given repository"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.refresh')
|
||||
repository_url = utils.add_repojson_to_url(repository_url)
|
||||
|
||||
repo_path = storage_path / 'repo.json'
|
||||
if repo_path.exists():
|
||||
|
Reference in New Issue
Block a user