artifacts: added reading of metadata and define basic audit-log entries for add/delete artifact

This commit is contained in:
Marcin Kuzminski 2019-05-15 17:23:35 +02:00
parent 4aeb810703
commit f91141b4bd
3 changed files with 20 additions and 4 deletions

View file

@ -209,3 +209,16 @@ class LocalFileStorage(object):
filename = os.path.join(directory, filename)
return filename, metadata
def get_metadata(self, filename):
"""
Reads JSON stored metadata for a file
:param filename:
:return:
"""
filename = self.store_path(filename)
filename_meta = filename + '.meta'
with open(filename_meta, "rb") as source_meta:
return json.loads(source_meta.read())

View file

@ -68,7 +68,7 @@ class FileStoreView(BaseAppView):
'user_id': self._rhodecode_user.user_id,
'ip': self._rhodecode_user.ip_addr}}
try:
store_fid, metadata = self.storage.save_file(
store_uid, metadata = self.storage.save_file(
file_obj.file, filename, extra_metadata=metadata)
except FileNotAllowedException:
return {'store_fid': None,
@ -82,7 +82,7 @@ class FileStoreView(BaseAppView):
try:
entry = FileStore.create(
file_uid=store_fid, filename=metadata["filename"],
file_uid=store_uid, filename=metadata["filename"],
file_hash=metadata["sha256"], file_size=metadata["size"],
file_description='upload attachment',
check_acl=False, user_id=self._rhodecode_user.user_id
@ -96,8 +96,8 @@ class FileStoreView(BaseAppView):
'access_path': None,
'error': 'File {} failed to store in DB.'.format(filename)}
return {'store_fid': store_fid,
'access_path': h.route_path('download_file', fid=store_fid)}
return {'store_fid': store_uid,
'access_path': h.route_path('download_file', fid=store_uid)}
@view_config(route_name='download_file')
def download_file(self):

View file

@ -92,6 +92,9 @@ ACTIONS_V1 = {
'repo.commit.comment.delete': {'data': {}},
'repo.commit.vote': '',
'repo.artifact.add': '',
'repo.artifact.delete': '',
'repo_group.create': {'data': {}},
'repo_group.edit': {'old_data': {}},
'repo_group.edit.permissions': {},