Show More
@@ -39,8 +39,8 b' from rhodecode.lib.utils2 import safe_in' | |||
|
39 | 39 | from rhodecode.model.db import UserIpMap |
|
40 | 40 | from rhodecode.model.scm import ScmModel |
|
41 | 41 | from rhodecode.model.settings import VcsSettingsModel |
|
42 |
from rhodecode.apps. |
|
|
43 |
from rhodecode.apps. |
|
|
42 | from rhodecode.apps.file_store import utils | |
|
43 | from rhodecode.apps.file_store.exceptions import FileNotAllowedException, \ | |
|
44 | 44 | FileOverSizeException |
|
45 | 45 | |
|
46 | 46 | log = logging.getLogger(__name__) |
@@ -469,7 +469,7 b' def upload_file(request, apiuser, filena' | |||
|
469 | 469 | 'user_id': apiuser.user_id, |
|
470 | 470 | 'ip': apiuser.ip_addr}} |
|
471 | 471 | try: |
|
472 | store_fid = storage.save_file(file_obj, filename, metadata=metadata) | |
|
472 | store_fid, metadata = storage.save_file(file_obj, filename, metadata=metadata) | |
|
473 | 473 | except FileNotAllowedException: |
|
474 | 474 | raise JSONRPCError('File `{}` is not allowed.'.format(filename)) |
|
475 | 475 |
@@ -18,7 +18,7 b'' | |||
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | import os |
|
21 |
from rhodecode.apps. |
|
|
21 | from rhodecode.apps.file_store import config_keys | |
|
22 | 22 | from rhodecode.config.middleware import _bool_setting, _string_setting |
|
23 | 23 | |
|
24 | 24 |
|
1 | NO CONTENT: file renamed from rhodecode/apps/upload_store/config_keys.py to rhodecode/apps/file_store/config_keys.py |
|
1 | NO CONTENT: file renamed from rhodecode/apps/upload_store/exceptions.py to rhodecode/apps/file_store/exceptions.py |
|
1 | NO CONTENT: file renamed from rhodecode/apps/upload_store/extensions.py to rhodecode/apps/file_store/extensions.py |
@@ -23,9 +23,9 b' import time' | |||
|
23 | 23 | import shutil |
|
24 | 24 | |
|
25 | 25 | from rhodecode.lib.ext_json import json |
|
26 |
from rhodecode.apps. |
|
|
27 |
from rhodecode.apps. |
|
|
28 |
from rhodecode.apps. |
|
|
26 | from rhodecode.apps.file_store import utils | |
|
27 | from rhodecode.apps.file_store.extensions import resolve_extensions | |
|
28 | from rhodecode.apps.file_store.exceptions import FileNotAllowedException | |
|
29 | 29 | |
|
30 | 30 | METADATA_VER = 'v1' |
|
31 | 31 | |
@@ -110,7 +110,8 b' class LocalFileStorage(object):' | |||
|
110 | 110 | Checks if an extension is permitted. Both e.g. ".jpg" and |
|
111 | 111 | "jpg" can be passed in. Extension lookup is case-insensitive. |
|
112 | 112 | |
|
113 |
:param ext |
|
|
113 | :param ext: extension to check | |
|
114 | :param extensions: iterable of extensions to validate against (or self.extensions) | |
|
114 | 115 | """ |
|
115 | 116 | |
|
116 | 117 | extensions = extensions or self.extensions |
@@ -160,12 +161,15 b' class LocalFileStorage(object):' | |||
|
160 | 161 | |
|
161 | 162 | if metadata: |
|
162 | 163 | size = os.stat(path).st_size |
|
163 |
metadata.update( |
|
|
164 | metadata.update( | |
|
165 | {"size": size, | |
|
166 | "time": time.time(), | |
|
164 | 167 |
|
|
168 | ||
|
165 | 169 | with open(os.path.join(dest_directory, filename_meta), "wb") as dest_meta: |
|
166 | 170 | dest_meta.write(json.dumps(metadata)) |
|
167 | 171 | |
|
168 | 172 | if directory: |
|
169 | 173 | filename = os.path.join(directory, filename) |
|
170 | 174 | |
|
171 | return filename | |
|
175 | return filename, metadata |
|
1 | NO CONTENT: file renamed from rhodecode/apps/upload_store/tests/__init__.py to rhodecode/apps/file_store/tests/__init__.py |
@@ -22,7 +22,7 b' import pytest' | |||
|
22 | 22 | |
|
23 | 23 | from rhodecode.lib.ext_json import json |
|
24 | 24 | from rhodecode.tests import TestController |
|
25 |
from rhodecode.apps. |
|
|
25 | from rhodecode.apps.file_store import utils, config_keys | |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | def route_path(name, params=None, **kwargs): |
@@ -58,7 +58,7 b' class TestFileStoreViews(TestController)' | |||
|
58 | 58 | f.write(content) |
|
59 | 59 | |
|
60 | 60 | with open(filesystem_file, 'rb') as f: |
|
61 | fid = store.save_file(f, fid, metadata={'filename': fid}) | |
|
61 | fid, metadata = store.save_file(f, fid, metadata={'filename': fid}) | |
|
62 | 62 | |
|
63 | 63 | else: |
|
64 | 64 | status = 404 |
@@ -24,8 +24,8 b' import uuid' | |||
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | def get_file_storage(settings): |
|
27 |
from rhodecode.apps. |
|
|
28 |
from rhodecode.apps. |
|
|
27 | from rhodecode.apps.file_store.local_store import LocalFileStorage | |
|
28 | from rhodecode.apps.file_store import config_keys | |
|
29 | 29 | store_path = settings.get(config_keys.store_path) |
|
30 | 30 | return LocalFileStorage(base_path=store_path) |
|
31 | 31 |
@@ -24,8 +24,8 b' from pyramid.response import FileRespons' | |||
|
24 | 24 | from pyramid.httpexceptions import HTTPFound, HTTPNotFound |
|
25 | 25 | |
|
26 | 26 | from rhodecode.apps._base import BaseAppView |
|
27 |
from rhodecode.apps. |
|
|
28 |
from rhodecode.apps. |
|
|
27 | from rhodecode.apps.file_store import utils | |
|
28 | from rhodecode.apps.file_store.exceptions import ( | |
|
29 | 29 | FileNotAllowedException,FileOverSizeException) |
|
30 | 30 | |
|
31 | 31 | from rhodecode.lib import helpers as h |
@@ -69,8 +69,7 b' class FileStoreView(BaseAppView):' | |||
|
69 | 69 | 'user_id': self._rhodecode_user.user_id, |
|
70 | 70 | 'ip': self._rhodecode_user.ip_addr}} |
|
71 | 71 | try: |
|
72 | store_fid = self.storage.save_file(file_obj.file, filename, | |
|
73 | metadata=metadata) | |
|
72 | store_fid, metadata = self.storage.save_file(file_obj.file, filename, metadata=metadata) | |
|
74 | 73 | except FileNotAllowedException: |
|
75 | 74 | return {'store_fid': None, |
|
76 | 75 | 'access_path': None, |
@@ -281,7 +281,7 b' def includeme(config):' | |||
|
281 | 281 | config.include('rhodecode.apps.ops') |
|
282 | 282 | config.include('rhodecode.apps.admin') |
|
283 | 283 | config.include('rhodecode.apps.channelstream') |
|
284 |
config.include('rhodecode.apps. |
|
|
284 | config.include('rhodecode.apps.file_store') | |
|
285 | 285 | config.include('rhodecode.apps.login') |
|
286 | 286 | config.include('rhodecode.apps.home') |
|
287 | 287 | config.include('rhodecode.apps.journal') |
General Comments 0
You need to be logged in to leave comments.
Login now