merge bookmark @

This commit is contained in:
Goffi 2021-09-26 16:41:49 +02:00
commit d7d40a6d50

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# SAT plugin for parrot mode (experimental)
# Libervia File Sharing component
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
# This program is free software: you can redistribute it and/or modify
@ -49,7 +49,7 @@ log = getLogger(__name__)
PLUGIN_INFO = {
C.PI_NAME: "File sharing component",
C.PI_IMPORT_NAME: "file_sharing",
C.PI_IMPORT_NAME: "file-sharing",
C.PI_MODES: [C.PLUG_MODE_COMPONENT],
C.PI_TYPE: C.PLUG_TYPE_ENTRY_POINT,
C.PI_PROTOCOLS: [],
@ -208,7 +208,7 @@ class HTTPFileServer(resource.Resource):
request.content = None
# the 2 following headers are not standard, but useful in the context of file
# sharing with HTTP Upload: first one allow uploaded to specify the path
# sharing with HTTP Upload: first one allow uploader to specify the path
# and second one will disable public exposure of the file through HTTP
path = request.getHeader("Xmpp-File-Path")
if path:
@ -244,7 +244,7 @@ class FileSharingRequest(server.Request):
@property
def upload_data(self):
"""A tuple with upload_id and filename retrieve from requested path"""
"""A tuple with upload_id and filename retrieved from requested path"""
if self._upload_data is not None:
return self._upload_data
@ -370,9 +370,9 @@ class FileSharing:
self._getDirectoryMetadataElts)
self.files_path = self.host.getLocalPath(None, C.FILES_DIR, profile=False)
self.http_port = int(self.host.memory.getConfig(
'component file_sharing', 'http_upload_port', 8888))
'component file-sharing', 'http_upload_port', 8888))
connection_type = self.host.memory.getConfig(
'component file_sharing', 'http_upload_connection_type', 'https')
'component file-sharing', 'http_upload_connection_type', 'https')
if connection_type not in ('http', 'https'):
raise exceptions.ConfigError(
'bad http_upload_connection_type, you must use one of "http" or "https"'
@ -383,7 +383,7 @@ class FileSharing:
reactor.listenTCP(self.http_port, self.server)
else:
options = tls.getOptionsFromConfig(
self.host.memory.config, "component file_sharing")
self.host.memory.config, "component file-sharing")
tls.TLSOptionsCheck(options)
context_factory = tls.getTLSContextFactory(options)
reactor.listenSSL(self.http_port, self.server, context_factory)
@ -394,7 +394,7 @@ class FileSharing:
def profileConnecting(self, client):
self.init()
public_base_url = self.host.memory.getConfig(
'component file_sharing', 'http_upload_public_facing_url')
'component file-sharing', 'http_upload_public_facing_url')
if public_base_url is None:
client._file_sharing_base_url = f"https://{client.host}:{self.http_port}"
else:
@ -410,7 +410,7 @@ class FileSharing:
def getQuota(self, client, entity):
"""Return maximum size allowed for all files for entity"""
# TODO: handle special entities like admins
quotas = self.host.memory.getConfig("component file_sharing", "quotas_json", {})
quotas = self.host.memory.getConfig("component file-sharing", "quotas_json", {})
entity_bare_s = entity.userhost()
try:
quota = quotas["jids"][entity_bare_s]