{"record":{"id":"f6cad914b9c1d04f","repo":"nextcloud/server","slug":"this-file-folder-is-already-in-that-directory","errorCode":null,"errorMessage":"This file/folder is already in that directory","messagePattern":"This file/folder is already in that directory","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/files/src/actions/moveOrCopyAction.ts","lineNumber":109,"sourceCode":" *\n * @param nodes The nodes to copy/move\n * @param destination The destination to copy/move the nodes to\n * @param method The method to use for the copy/move\n * @param overwrite Whether to overwrite the destination if it exists\n * @yields {AsyncGenerator<void, void, never>} A promise that resolves when the copy/move is done\n */\nexport async function* handleCopyMoveNodesTo(nodes: INode[], destination: IFolder, method: MoveCopyAction.COPY | MoveCopyAction.MOVE, overwrite = false): AsyncGenerator<void, void, never> {\n\tif (!destination) {\n\t\treturn\n\t}\n\n\tif (destination.type !== FileType.Folder) {\n\t\tthrow new Error(t('files', 'Destination is not a folder'))\n\t}\n\n\t// Do not allow to MOVE a node to the same folder it is already located\n\tif (method === MoveCopyAction.MOVE && nodes.some((node) => node.dirname === destination.path)) {\n\t\tthrow new Error(t('files', 'This file/folder is already in that directory'))\n\t}\n\n\t/**\n\t * Example:\n\t * - node: /foo/bar/file.txt -> path = /foo/bar/file.txt, destination: /foo\n\t *   Allow move of /foo does not start with /foo/bar/file.txt so allow\n\t * - node: /foo , destination: /foo/bar\n\t *   Do not allow as it would copy foo within itself\n\t * - node: /foo/bar.txt, destination: /foo\n\t *   Allow copy a file to the same directory\n\t * - node: \"/foo/bar\", destination: \"/foo/bar 1\"\n\t *   Allow to move or copy but we need to check with trailing / otherwise it would report false positive\n\t */\n\tif (nodes.some((node) => `${destination.path}/`.startsWith(`${node.path}/`))) {\n\t\tthrow new Error(t('files', 'You cannot move a file/folder onto itself or into a subfolder of itself'))\n\t}\n\n\tconst nameMapping = new Map<string, string>()","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/files/src/actions/moveOrCopyAction.ts#L91-L127","documentation":"Error \"This file/folder is already in that directory\" thrown in nextcloud/server.","triggerScenarios":"Thrown at apps/files/src/actions/moveOrCopyAction.ts:109 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}