1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 07:22:34 +00:00

repair history bug (#5470)

* repair history bug

* optimize code
This commit is contained in:
杨顺强
2023-05-13 22:15:57 +08:00
committed by GitHub
parent 4ee7ce094e
commit 22ce9ac1a2
3 changed files with 43 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ import { UncontrolledTooltip } from 'reactstrap';
import classnames from 'classnames'; import classnames from 'classnames';
import DiffViewer from '@seafile/sdoc-editor/dist/pages/diff-viewer'; import DiffViewer from '@seafile/sdoc-editor/dist/pages/diff-viewer';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
import { gettext, fileName, historyRepoID } from '../../utils/constants'; import { gettext, historyRepoID } from '../../utils/constants';
import Loading from '../../components/loading'; import Loading from '../../components/loading';
import GoBack from '../../components/common/go-back'; import GoBack from '../../components/common/go-back';
import SidePanel from './side-panel'; import SidePanel from './side-panel';
@@ -14,6 +14,24 @@ import toaster from '../../components/toast';
import '../../css/layout.css'; import '../../css/layout.css';
import '../../css/sdoc-file-history.css'; import '../../css/sdoc-file-history.css';
const { serviceURL, avatarURL, siteRoot } = window.app.config;
const { username, name } = window.app.pageOptions;
const { repoID, fileName, filePath, docUuid, assetsUrl } = window.fileHistory.pageOptions;
window.seafile = {
repoID,
docPath: filePath,
docName: fileName,
docUuid,
isOpenSocket: false,
serviceUrl: serviceURL,
name,
username,
avatarURL,
siteRoot,
assetsUrl,
};
class SdocFileHistory extends React.Component { class SdocFileHistory extends React.Component {
constructor(props) { constructor(props) {

View File

@@ -14,8 +14,10 @@
repoName: '{{ repo.name }}', repoName: '{{ repo.name }}',
filePath: '{{ path|escapejs }}', filePath: '{{ path|escapejs }}',
fileName: '{{ u_filename|escapejs }}', fileName: '{{ u_filename|escapejs }}',
docUuid: '{{ file_uuid }}',
domain: '{{ domain }}', domain: '{{ domain }}',
protocol: '{{ protocol }}', protocol: '{{ protocol }}',
assetsUrl: '{{ assets_url }}',
} }
} }
</script> </script>

View File

@@ -36,13 +36,15 @@ from seahub.options.models import UserOptions, CryptoOptionNotSetError
from seahub.profile.models import Profile from seahub.profile.models import Profile
from seahub.share.models import FileShare, UploadLinkShare from seahub.share.models import FileShare, UploadLinkShare
from seahub.revision_tag.models import RevisionTags from seahub.revision_tag.models import RevisionTags
from seahub.tags.models import FileUUIDMap
from seahub.utils import render_permission_error, render_error, \ from seahub.utils import render_permission_error, render_error, \
gen_shared_upload_link, is_org_context, \ gen_shared_upload_link, is_org_context, \
gen_dir_share_link, gen_file_share_link, get_file_type_and_ext, \ gen_dir_share_link, gen_file_share_link, get_file_type_and_ext, \
get_user_repos, EMPTY_SHA1, gen_file_get_url, \ get_user_repos, EMPTY_SHA1, gen_file_get_url, \
new_merge_with_no_conflict, get_max_upload_file_size, \ new_merge_with_no_conflict, get_max_upload_file_size, \
is_pro_version, FILE_AUDIT_ENABLED, is_valid_dirent_name, \ is_pro_version, FILE_AUDIT_ENABLED, is_valid_dirent_name, \
is_windows_operating_system, get_file_history_suffix, IS_EMAIL_CONFIGURED is_windows_operating_system, get_file_history_suffix, IS_EMAIL_CONFIGURED, \
normalize_file_path
from seahub.utils.star import get_dir_starred_files from seahub.utils.star import get_dir_starred_files
from seahub.utils.repo import get_library_storages, parse_repo_perm from seahub.utils.repo import get_library_storages, parse_repo_perm
from seahub.utils.file_op import check_file_lock from seahub.utils.file_op import check_file_lock
@@ -120,6 +122,22 @@ def check_folder_permission(request, repo_id, path):
username = request.user.username username = request.user.username
return seafile_api.check_permission_by_path(repo_id, path, username) return seafile_api.check_permission_by_path(repo_id, path, username)
def get_seadoc_file_uuid(repo, path):
repo_id = repo.repo_id
if repo.is_virtual:
repo_id = repo.origin_repo_id
path = posixpath.join(repo.origin_path, path.strip('/'))
path = normalize_file_path(path)
parent_dir = os.path.dirname(path)
filename = os.path.basename(path)
uuid_map = FileUUIDMap.objects.get_or_create_fileuuidmap(
repo_id, parent_dir, filename, is_dir=False)
file_uuid = str(uuid_map.uuid) # 36 chars str
return file_uuid
def gen_path_link(path, repo_name): def gen_path_link(path, repo_name):
""" """
Generate navigate paths and links in repo page. Generate navigate paths and links in repo page.
@@ -779,14 +797,17 @@ def file_revisions(request, repo_id):
can_revert_file = False can_revert_file = False
if file_type == 'sdoc': if file_type == 'sdoc':
file_uuid = get_seadoc_file_uuid(repo, path)
return render(request, 'sdoc_file_revisions.html', { return render(request, 'sdoc_file_revisions.html', {
'repo': repo, 'repo': repo,
'path': path, 'path': path,
'u_filename': u_filename, 'u_filename': u_filename,
'file_uuid': file_uuid,
'zipped': zipped, 'zipped': zipped,
'is_owner': is_owner, 'is_owner': is_owner,
'can_compare': can_compare, 'can_compare': can_compare,
'can_revert_file': can_revert_file, 'can_revert_file': can_revert_file,
'assets_url': '/api/v2.1/seadoc/download-image/' + file_uuid
}) })
# Whether use new file history API which read file history from db. # Whether use new file history API which read file history from db.