1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 01:41:39 +00:00

repair move&copy bug (#3020)

* repair move&copy bug

* [fix bug] file move filetag disappear
This commit is contained in:
杨顺强
2019-03-01 14:40:39 +08:00
committed by Daniel Pan
parent 907105a262
commit 1e2c06c084
3 changed files with 26 additions and 20 deletions

View File

@@ -41,6 +41,7 @@ class FileChooser extends React.Component {
currentRepoInfo: repoInfo,
selectedRepo: repoInfo
});
this.props.onRepoItemClick(repoInfo);
});
}
}

View File

@@ -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',
),
]

View File

@@ -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()