mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 10:22:46 +00:00
repair move© bug (#3020)
* repair move© bug * [fix bug] file move filetag disappear
This commit is contained in:
@@ -41,6 +41,7 @@ class FileChooser extends React.Component {
|
|||||||
currentRepoInfo: repoInfo,
|
currentRepoInfo: repoInfo,
|
||||||
selectedRepo: repoInfo
|
selectedRepo: repoInfo
|
||||||
});
|
});
|
||||||
|
this.props.onRepoItemClick(repoInfo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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',
|
||||||
|
),
|
||||||
|
]
|
@@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import os
|
import os
|
||||||
|
import hashlib
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from seahub.repo_tags.models import RepoTags
|
from seahub.repo_tags.models import RepoTags
|
||||||
from seahub.tags.models import FileUUIDMap
|
from seahub.tags.models import FileUUIDMap
|
||||||
@@ -13,15 +14,12 @@ class FileTagsManager(models.Manager):
|
|||||||
file_path = normalize_file_path(file_path)
|
file_path = normalize_file_path(file_path)
|
||||||
filename = os.path.basename(file_path)
|
filename = os.path.basename(file_path)
|
||||||
parent_path = os.path.dirname(file_path)
|
parent_path = os.path.dirname(file_path)
|
||||||
folder_name = os.path.dirname(parent_path)
|
|
||||||
|
|
||||||
file_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path(
|
file_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path(
|
||||||
repo_id, parent_path, filename, is_dir=False)
|
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_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()
|
file_tags = list()
|
||||||
for file_tag in file_tag_list:
|
for file_tag in file_tag_list:
|
||||||
@@ -44,16 +42,12 @@ class FileTagsManager(models.Manager):
|
|||||||
file_path = normalize_file_path(file_path)
|
file_path = normalize_file_path(file_path)
|
||||||
filename = os.path.basename(file_path)
|
filename = os.path.basename(file_path)
|
||||||
parent_path = os.path.dirname(file_path)
|
parent_path = os.path.dirname(file_path)
|
||||||
folder_name = os.path.dirname(parent_path)
|
|
||||||
|
|
||||||
file_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path(
|
file_uuid = FileUUIDMap.objects.get_fileuuidmap_by_path(
|
||||||
repo_id, parent_path, filename, is_dir=False)
|
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:
|
try:
|
||||||
return super(FileTagsManager, self).get(repo_tag_id=repo_tag_id,
|
return super(FileTagsManager, self).get(repo_tag_id=repo_tag_id,
|
||||||
file_uuid=file_uuid,
|
file_uuid=file_uuid)
|
||||||
parent_folder_uuid=parent_folder_uuid)
|
|
||||||
except self.model.DoesNotExist:
|
except self.model.DoesNotExist:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -61,15 +55,10 @@ class FileTagsManager(models.Manager):
|
|||||||
file_path = normalize_file_path(file_path)
|
file_path = normalize_file_path(file_path)
|
||||||
filename = os.path.basename(file_path)
|
filename = os.path.basename(file_path)
|
||||||
parent_path = os.path.dirname(file_path)
|
parent_path = os.path.dirname(file_path)
|
||||||
folder_name = os.path.dirname(parent_path)
|
|
||||||
file_uuid = FileUUIDMap.objects.get_or_create_fileuuidmap(
|
file_uuid = FileUUIDMap.objects.get_or_create_fileuuidmap(
|
||||||
repo_id, parent_path, filename, is_dir=False)
|
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)
|
repo_tag = RepoTags.objects.get_repo_tag_by_id(repo_tag_id)
|
||||||
file_tag = self.model(repo_tag=repo_tag,
|
file_tag = self.model(repo_tag=repo_tag, file_uuid=file_uuid)
|
||||||
file_uuid=file_uuid,
|
|
||||||
parent_folder_uuid=parent_folder_uuid)
|
|
||||||
file_tag.save()
|
file_tag.save()
|
||||||
return file_tag
|
return file_tag
|
||||||
|
|
||||||
@@ -84,18 +73,15 @@ class FileTagsManager(models.Manager):
|
|||||||
def get_dir_file_tags(self, repo_id, path):
|
def get_dir_file_tags(self, repo_id, path):
|
||||||
|
|
||||||
parent_path = os.path.dirname(path)
|
parent_path = os.path.dirname(path)
|
||||||
folder_name = os.path.dirname(parent_path)
|
repo_id_parent_path_md5 = hashlib.md5((repo_id + parent_path).encode('utf-8')).hexdigest()
|
||||||
parent_folder_uuid = FileUUIDMap.objects.get_or_create_fileuuidmap(
|
|
||||||
repo_id, parent_path, folder_name, is_dir=True)
|
|
||||||
|
|
||||||
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):
|
class FileTags(models.Model):
|
||||||
|
|
||||||
repo_tag = models.ForeignKey(RepoTags, db_index=True, on_delete=models.CASCADE)
|
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')
|
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()
|
objects = FileTagsManager()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user