Beispiel #1
0
def post_file_to_channel(
        background_tasks: BackgroundTasks,
        files: List[UploadFile] = File(...),
        force: Optional[bool] = Form(None),
        channel: db_models.Channel = Depends(
            ChannelChecker(allow_proxy=False, allow_mirror=False)),
        dao: Dao = Depends(get_dao),
        auth: authorization.Rules = Depends(get_rules),
):
    handle_package_files(channel, files, dao, auth, force)

    dao.update_channel_size(channel.name)

    # Background task to update indexes
    background_tasks.add_task(indexing.update_indexes, dao, pkgstore,
                              channel.name)
Beispiel #2
0
def post_file_to_package(
    background_tasks: BackgroundTasks,
    files: List[UploadFile] = File(...),
    force: Optional[bool] = Form(None),
    package: db_models.Package = Depends(get_package_or_fail),
    dao: Dao = Depends(get_dao),
    auth: authorization.Rules = Depends(get_rules),
    channel: db_models.Channel = Depends(
        ChannelChecker(allow_proxy=False, allow_mirror=False), ),
):
    handle_package_files(package.channel,
                         files,
                         dao,
                         auth,
                         force,
                         package=package)
    dao.update_channel_size(package.channel_name)
Beispiel #3
0
def post_package(
        new_package: rest_models.Package,
        channel: db_models.Channel = Depends(
            ChannelChecker(allow_proxy=False, allow_mirror=False), ),
        auth: authorization.Rules = Depends(get_rules),
        dao: Dao = Depends(get_dao),
):

    user_id = auth.assert_user()
    auth.assert_create_package(channel.name)
    pm.hook.validate_new_package(
        channel_name=channel.name,
        package_name=new_package.name,
        file_handler=None,
        condainfo=None,
    )
    package = dao.get_package(channel.name, new_package.name)
    if package:
        raise HTTPException(
            status_code=status.HTTP_409_CONFLICT,
            detail=f"Package {channel.name}/{new_package.name} exists",
        )

    dao.create_package(channel.name, new_package, user_id, authorization.OWNER)