Storage/XRootD: Support sending file via FUSE

Like this the webserver can deal with the file instead of sending
possibly large amounts of data though Indico itself.
This commit is contained in:
Adrian Moennich 2017-05-04 18:17:51 +02:00
parent a878c88d43
commit 06ba97a74d

View File

@ -16,6 +16,7 @@
from __future__ import unicode_literals
import ast
import os
import shutil
import sys
@ -46,10 +47,13 @@ class XRootDStoragePlugin(IndicoPlugin):
class XRootDStorage(Storage):
name = 'xrootd'
simple_data = True
simple_data = False
def __init__(self, data):
self.xrootd_host, self.path = data.split(':', 1)
data = self._parse_data(data)
self.xrootd_host = data['host']
self.path = data['root']
self.fuse = bool(ast.literal_eval(data.get('fuse', 'False').title()))
@return_ascii
def __repr__(self):
@ -105,4 +109,5 @@ class XRootDStorage(Storage):
raise StorageError('Could not get size of "{}": {}'.format(file_id, e)), None, sys.exc_info()[2]
def send_file(self, file_id, content_type, filename, inline=True):
return send_file(filename, self.open(file_id), content_type, inline=inline)
file_data = self._resolve_path(file_id) if self.fuse else self.open(file_id)
return send_file(filename, file_data, content_type, inline=inline)