fix(server/files): duplicate entry when making a nested folder (#3813)

This commit is contained in:
Mrxbox98 2022-01-18 11:49:06 -08:00 committed by GitHub
parent 5f308feb3f
commit 1f3217c3c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,8 +22,8 @@ import { FileActionCheckbox } from '@/components/server/files/SelectFileCheckbox
import { hashToPath } from '@/helpers'; import { hashToPath } from '@/helpers';
const sortFiles = (files: FileObject[]): FileObject[] => { const sortFiles = (files: FileObject[]): FileObject[] => {
return files.sort((a, b) => a.name.localeCompare(b.name)) const sortedFiles: FileObject[] = files.sort((a, b) => a.name.localeCompare(b.name)).sort((a, b) => a.isFile === b.isFile ? 0 : (a.isFile ? 1 : -1));
.sort((a, b) => a.isFile === b.isFile ? 0 : (a.isFile ? 1 : -1)); return sortedFiles.filter((file, index) => index === 0 || file.name !== sortedFiles[index - 1].name);
}; };
export default () => { export default () => {