diff --git a/frontend/src/components/file-chooser/file-chooser.js b/frontend/src/components/file-chooser/file-chooser.js index cbd2d2103a..b74db4a7e0 100644 --- a/frontend/src/components/file-chooser/file-chooser.js +++ b/frontend/src/components/file-chooser/file-chooser.js @@ -41,6 +41,7 @@ class FileChooser extends React.Component { currentRepoInfo: repoInfo, selectedRepo: repoInfo }); + this.props.onRepoItemClick(repoInfo); }); } } diff --git a/seahub/file_tags/migrations/0002_remove_filetags_parent_folder_uuid.py b/seahub/file_tags/migrations/0002_remove_filetags_parent_folder_uuid.py new file mode 100644 index 0000000000..11891b901e --- /dev/null +++ b/seahub/file_tags/migrations/0002_remove_filetags_parent_folder_uuid.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.15 on 2019-03-01 02:16 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('file_tags', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='filetags', + name='parent_folder_uuid', + ), + ] diff --git a/seahub/file_tags/models.py b/seahub/file_tags/models.py index 2e395613e2..98cda4b4e5 100644 --- a/seahub/file_tags/models.py +++ b/seahub/file_tags/models.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals import os +import hashlib from django.db import models from seahub.repo_tags.models import RepoTags from seahub.tags.models import FileUUIDMap @@ -13,15 +14,12 @@ class FileTagsManager(models.Manager): file_path = normalize_file_path(file_path) filename = os.path.basename(file_path) parent_path = os.path.dirname(file_path) - folder_name = os.path.dirname(parent_path) file_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path( repo_id, parent_path, filename, is_dir=False) - parent_folder_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path( - repo_id, parent_path, folder_name, is_dir=True) file_tag_list = super(FileTagsManager, self).filter( - file_uuid=file_uuid, parent_folder_uuid=parent_folder_uuid).select_related('repo_tag') + file_uuid=file_uuid).select_related('repo_tag') file_tags = list() for file_tag in file_tag_list: @@ -44,16 +42,12 @@ class FileTagsManager(models.Manager): file_path = normalize_file_path(file_path) filename = os.path.basename(file_path) parent_path = os.path.dirname(file_path) - folder_name = os.path.dirname(parent_path) file_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path( repo_id, parent_path, filename, is_dir=False) - parent_folder_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path( - repo_id, parent_path, folder_name, is_dir=True) try: return super(FileTagsManager, self).get(repo_tag_id=repo_tag_id, - file_uuid=file_uuid, - parent_folder_uuid=parent_folder_uuid) + file_uuid=file_uuid) except self.model.DoesNotExist: return None @@ -61,15 +55,10 @@ class FileTagsManager(models.Manager): file_path = normalize_file_path(file_path) filename = os.path.basename(file_path) parent_path = os.path.dirname(file_path) - folder_name = os.path.dirname(parent_path) file_uuid = FileUUIDMap.objects.get_or_create_fileuuidmap( repo_id, parent_path, filename, is_dir=False) - parent_folder_uuid = FileUUIDMap.objects.get_or_create_fileuuidmap( - repo_id, parent_path, folder_name, is_dir=True) repo_tag = RepoTags.objects.get_repo_tag_by_id(repo_tag_id) - file_tag = self.model(repo_tag=repo_tag, - file_uuid=file_uuid, - parent_folder_uuid=parent_folder_uuid) + file_tag = self.model(repo_tag=repo_tag, file_uuid=file_uuid) file_tag.save() return file_tag @@ -84,18 +73,15 @@ class FileTagsManager(models.Manager): def get_dir_file_tags(self, repo_id, path): parent_path = os.path.dirname(path) - folder_name = os.path.dirname(parent_path) - parent_folder_uuid = FileUUIDMap.objects.get_or_create_fileuuidmap( - repo_id, parent_path, folder_name, is_dir=True) + repo_id_parent_path_md5 = hashlib.md5((repo_id + parent_path).encode('utf-8')).hexdigest() - return super(FileTagsManager, self).filter(parent_folder_uuid=parent_folder_uuid) + return super(FileTagsManager, self).filter(file_uuid__repo_id_parent_path_md5=repo_id_parent_path_md5) class FileTags(models.Model): repo_tag = models.ForeignKey(RepoTags, db_index=True, on_delete=models.CASCADE) file_uuid = models.ForeignKey(FileUUIDMap, on_delete=models.CASCADE, related_name='file_uuid') - parent_folder_uuid = models.ForeignKey(FileUUIDMap, on_delete=models.CASCADE, related_name='parent_folder_uuid') objects = FileTagsManager()