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