diff --git a/swh/web/ui/main.py b/swh/web/ui/main.py --- a/swh/web/ui/main.py +++ b/swh/web/ui/main.py @@ -23,9 +23,6 @@ 'host': ('string', '127.0.0.1'), 'port': ('int', 6543), 'secret_key': ('string', 'development key'), - 'max_upload_size': ('int', 16 * 1024 * 1024), - 'upload_folder': ('string', '/tmp/swh-web-ui/uploads'), - 'upload_allowed_extensions': ('list[str]', []) # means all are accepted } @@ -44,7 +41,7 @@ dict""" conf = config.read(config_file, DEFAULT_CONFIG) - config.prepare_folders(conf, 'log_dir', 'upload_folder') + config.prepare_folders(conf, 'log_dir') conf['storage'] = get_storage(conf['storage_class'], conf['storage_args']) return conf @@ -100,7 +97,6 @@ app.secret_key = conf['secret_key'] app.config['conf'] = conf - app.config['MAX_CONTENT_LENGTH'] = conf['max_upload_size'] app.config['DEFAULT_RENDERERS'] = RENDERERS logging.basicConfig(filename=os.path.join(conf['log_dir'], 'web-ui.log'), @@ -136,7 +132,6 @@ app.secret_key = conf['secret_key'] app.config['conf'] = conf - app.config['MAX_CONTENT_LENGTH'] = conf['max_upload_size'] app.config['DEFAULT_RENDERERS'] = RENDERERS host = conf.get('host', '127.0.0.1') diff --git a/swh/web/ui/service.py b/swh/web/ui/service.py --- a/swh/web/ui/service.py +++ b/swh/web/ui/service.py @@ -30,29 +30,6 @@ return hashes -def hash_and_search(filepath): - """Hash the filepath's content as sha1, then search in storage if - it exists. - - Args: - Filepath of the file to hash and search. - - Returns: - Tuple (hex sha1, found as True or false). - The found boolean, according to whether the sha1 of the file - is present or not. - """ - h = hashutil.hashfile(filepath) - c = backend.content_find('sha1', h['sha1']) - if c: - r = converters.from_content(c) - r['found'] = True - return r - else: - return {'sha1': hashutil.hash_to_hex(h['sha1']), - 'found': False} - - def lookup_hash(q): """Checks if the storage contains a given content checksum diff --git a/swh/web/ui/tests/test_app.py b/swh/web/ui/tests/test_app.py --- a/swh/web/ui/tests/test_app.py +++ b/swh/web/ui/tests/test_app.py @@ -48,12 +48,8 @@ # inject the mock data conf = {'storage': storage, - 'upload_folder': '/some/upload-dir', - 'upload_allowed_extensions': ['txt'], - 'max_upload_size': 1024} main.app.config.update({'conf': conf}) - main.app.config['MAX_CONTENT_LENGTH'] = conf['max_upload_size'] main.app.config['DEFAULT_RENDERERS'] = renderers.RENDERERS if not main.app.config['TESTING']: # HACK: install controllers only once! diff --git a/swh/web/ui/tests/test_service.py b/swh/web/ui/tests/test_service.py --- a/swh/web/ui/tests/test_service.py +++ b/swh/web/ui/tests/test_service.py @@ -351,54 +351,6 @@ mock_backend.stat_origin_visits.assert_called_once_with(6) @patch('swh.web.ui.service.backend') - @patch('swh.web.ui.service.hashutil') - @istest - def hash_and_search(self, mock_hashutil, mock_backend): - # given - bhash = hex_to_hash('456caf10e9535160d90e874b45aa426de762f19f') - mock_hashutil.hashfile.return_value = {'sha1': bhash} - mock_backend.content_find = MagicMock(return_value={ - 'sha1': bhash, - 'sha1_git': bhash, - }) - - # when - actual_content = service.hash_and_search('/some/path') - - # then - self.assertEqual(actual_content, { - 'sha1': '456caf10e9535160d90e874b45aa426de762f19f', - 'sha1_git': '456caf10e9535160d90e874b45aa426de762f19f', - 'found': True, - }) - - mock_hashutil.hashfile.assert_called_once_with('/some/path') - mock_backend.content_find.assert_called_once_with('sha1', bhash) - - @patch('swh.web.ui.service.hashutil') - @istest - def hash_and_search_not_found(self, mock_hashutil): - # given - bhash = hex_to_hash('456caf10e9535160d90e874b45aa426de762f19f') - mock_hashutil.hashfile.return_value = {'sha1': bhash} - mock_hashutil.hash_to_hex = MagicMock( - return_value='456caf10e9535160d90e874b45aa426de762f19f') - self.storage.content_find = MagicMock(return_value=None) - - # when - actual_content = service.hash_and_search('/some/path') - - # then - self.assertEqual(actual_content, { - 'sha1': '456caf10e9535160d90e874b45aa426de762f19f', - 'found': False, - }) - - mock_hashutil.hashfile.assert_called_once_with('/some/path') - self.storage.content_find.assert_called_once_with({'sha1': bhash}) - mock_hashutil.hash_to_hex.assert_called_once_with(bhash) - - @patch('swh.web.ui.service.backend') @istest def lookup_origin(self, mock_backend): # given