Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
孙永强 committed May 31, 2024
1 parent b873339 commit aa7e311
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions seahub/api2/endpoints/dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from seaserv import seafile_api
from pysearpc import SearpcError

from seafevents import seafevents_api
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -577,7 +576,7 @@ def delete(self, request, repo_id, format=None):
'size': dir_obj.size
}
try:
from seahub.utils import SeafEventsSession
from seahub.utils import SeafEventsSession, seafevents_api
session = SeafEventsSession()
seafile_api.del_file(repo_id, parent_dir,
json.dumps([dir_name]), username)
Expand Down
3 changes: 1 addition & 2 deletions seahub/api2/endpoints/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

from seaserv import seafile_api
from pysearpc import SearpcError
from seafevents import seafevents_api

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -876,7 +875,7 @@ def delete(self, request, repo_id, format=None):
'size': file_size
}
try:
from seahub.utils import SeafEventsSession
from seahub.utils import SeafEventsSession, seafevents_api
session = SeafEventsSession()
seafile_api.del_file(repo_id, parent_dir,
json.dumps([file_name]),
Expand Down
4 changes: 2 additions & 2 deletions seahub/api2/endpoints/repo_trash.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
from seahub.api2.endpoints.group_owned_libraries import get_group_id_by_repo_owner

from seaserv import seafile_api
from seafevents import seafevents_api
from seahub.utils import SeafEventsSession

from pysearpc import SearpcError
from constance import config
Expand Down Expand Up @@ -389,6 +387,7 @@ def post(self, request, repo_id, format=None):
show_time = show_days

try:
from seahub.utils import SeafEventsSession, seafevents_api
session = SeafEventsSession()
deleted_entries = seafevents_api.get_delete_records(session, repo_id, show_time, path)
session.close()
Expand Down Expand Up @@ -456,6 +455,7 @@ def delete(self, request, repo_id, format=None):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
from seahub.utils import SeafEventsSession, seafevents_api
session = SeafEventsSession()
seafevents_api.clean_up_repo_trash(session, repo_id, keep_days)
session.close()
Expand Down
5 changes: 3 additions & 2 deletions seahub/api2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@
create_org, ccnet_api

from constance import config
from seafevents import seafevents_api
from seahub.utils import SeafEventsSession


logger = logging.getLogger(__name__)
json_content_type = 'application/json; charset=utf-8'
Expand Down Expand Up @@ -3353,6 +3352,7 @@ def put(self, request, repo_id, format=None):
file_name = os.path.basename(path)
parent_path = os.path.dirname(path)
try:
from seahub.utils import SeafEventsSession, seafevents_api
session = SeafEventsSession()
seafile_api.revert_file(repo_id, commit_id, path, username)
seafevents_api.restore_repo_trash(session, repo_id, file_name, parent_path)
Expand Down Expand Up @@ -3860,6 +3860,7 @@ def put(self, request, repo_id):
dir_name = os.path.basename(path)
username = request.user.username
try:
from seahub.utils import SeafEventsSession, seafevents_api
session = SeafEventsSession()
seafile_api.revert_dir(repo_id, commit_id, path, username)
seafevents_api.restore_repo_trash(session, repo_id, dir_name, parent_dir)
Expand Down

0 comments on commit aa7e311

Please sign in to comment.