more robust recursive folder check
Some checks failed
Lint / pnpm_install (pull_request) Successful in 1m53s
Publish Docker image / Build (pull_request) Successful in 4m58s
Test (production install and build) / production (20.16.0) (pull_request) Successful in 1m11s
Test (backend) / unit (20.16.0) (pull_request) Successful in 7m54s
Lint / lint (backend) (pull_request) Has been cancelled
Lint / lint (frontend) (pull_request) Has been cancelled
Lint / lint (frontend-embed) (pull_request) Has been cancelled
Lint / lint (frontend-shared) (pull_request) Has been cancelled
Lint / lint (misskey-bubble-game) (pull_request) Has been cancelled
Lint / lint (misskey-js) (pull_request) Has been cancelled
Lint / lint (misskey-reversi) (pull_request) Has been cancelled
Lint / lint (sw) (pull_request) Has been cancelled
Lint / typecheck (backend) (pull_request) Has been cancelled
Lint / typecheck (misskey-js) (pull_request) Has been cancelled
Lint / typecheck (sw) (pull_request) Has been cancelled
Test (backend) / e2e (20.16.0) (pull_request) Has been cancelled
Some checks failed
Lint / pnpm_install (pull_request) Successful in 1m53s
Publish Docker image / Build (pull_request) Successful in 4m58s
Test (production install and build) / production (20.16.0) (pull_request) Successful in 1m11s
Test (backend) / unit (20.16.0) (pull_request) Successful in 7m54s
Lint / lint (backend) (pull_request) Has been cancelled
Lint / lint (frontend) (pull_request) Has been cancelled
Lint / lint (frontend-embed) (pull_request) Has been cancelled
Lint / lint (frontend-shared) (pull_request) Has been cancelled
Lint / lint (misskey-bubble-game) (pull_request) Has been cancelled
Lint / lint (misskey-js) (pull_request) Has been cancelled
Lint / lint (misskey-reversi) (pull_request) Has been cancelled
Lint / lint (sw) (pull_request) Has been cancelled
Lint / typecheck (backend) (pull_request) Has been cancelled
Lint / typecheck (misskey-js) (pull_request) Has been cancelled
Lint / typecheck (sw) (pull_request) Has been cancelled
Test (backend) / e2e (20.16.0) (pull_request) Has been cancelled
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
parent
7a106a390d
commit
fee5f29ec7
2 changed files with 11 additions and 7 deletions
|
@ -32,7 +32,7 @@ export const meta = {
|
|||
},
|
||||
|
||||
recursiveNesting: {
|
||||
message: 'It can not be structured like nesting folders recursively.',
|
||||
message: 'Folders are linked recursively or too deeply.',
|
||||
code: 'RECURSIVE_NESTING',
|
||||
id: 'dbeb024837894013aed44279f9199740',
|
||||
},
|
||||
|
@ -94,7 +94,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
// Check if the circular reference will occur
|
||||
const checkCircle = async (folderId: string): Promise<boolean> => {
|
||||
const checkCircle = async (folderId: string, limit: number = 32): Promise<boolean> => {
|
||||
if (limit <= 0) {
|
||||
return false;
|
||||
}
|
||||
const folder2 = await this.driveFoldersRepository.findOneByOrFail({
|
||||
id: folderId,
|
||||
});
|
||||
|
@ -102,7 +105,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (folder2.id === folder.id) {
|
||||
return true;
|
||||
} else if (folder2.parentId) {
|
||||
return await checkCircle(folder2.parentId);
|
||||
return await checkCircle(folder2.parentId, limit - 1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -927,14 +927,15 @@ describe('Endpoints', () => {
|
|||
const folderC = (await api('drive/folders/create', {
|
||||
name: 'test',
|
||||
}, alice)).body;
|
||||
await api('drive/folders/update', {
|
||||
assert.ok(folderA.id && folderB.id && folderC.id);
|
||||
assert.strictEqual((await api('drive/folders/update', {
|
||||
folderId: folderB.id,
|
||||
parentId: folderA.id,
|
||||
}, alice);
|
||||
await api('drive/folders/update', {
|
||||
}, alice)).status, 200);
|
||||
assert.strictEqual((await api('drive/folders/update', {
|
||||
folderId: folderC.id,
|
||||
parentId: folderB.id,
|
||||
}, alice);
|
||||
}, alice)).status, 200);
|
||||
|
||||
const res = await api('drive/folders/update', {
|
||||
folderId: folderA.id,
|
||||
|
|
Loading…
Reference in a new issue