mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
@@ -1815,6 +1815,11 @@ class FileView(APIView):
|
|||||||
|
|
||||||
operation = request.DATA.get('operation', '')
|
operation = request.DATA.get('operation', '')
|
||||||
if operation.lower() == 'lock':
|
if operation.lower() == 'lock':
|
||||||
|
|
||||||
|
is_locked, locked_by_me = check_file_lock(repo_id, path, username)
|
||||||
|
if is_locked:
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, 'File is already locked')
|
||||||
|
|
||||||
# lock file
|
# lock file
|
||||||
expire = request.DATA.get('expire', FILE_LOCK_EXPIRATION_DAYS)
|
expire = request.DATA.get('expire', FILE_LOCK_EXPIRATION_DAYS)
|
||||||
try:
|
try:
|
||||||
@@ -1824,6 +1829,13 @@ class FileView(APIView):
|
|||||||
logger.error(e)
|
logger.error(e)
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal error')
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal error')
|
||||||
if operation.lower() == 'unlock':
|
if operation.lower() == 'unlock':
|
||||||
|
|
||||||
|
is_locked, locked_by_me = check_file_lock(repo_id, path, username)
|
||||||
|
if not is_locked:
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, 'File is not locked')
|
||||||
|
if not locked_by_me:
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, 'You can not unlock this file')
|
||||||
|
|
||||||
# unlock file
|
# unlock file
|
||||||
try:
|
try:
|
||||||
seafile_api.unlock_file(repo_id, path.lstrip('/'))
|
seafile_api.unlock_file(repo_id, path.lstrip('/'))
|
||||||
|
Reference in New Issue
Block a user