{"record":{"id":"2acaad99399b9072","repo":"AlistGo/alist","slug":"same-name-files-cannot-be-copied","errorCode":null,"errorMessage":"same-name files cannot be copied","messagePattern":"same-name files cannot be copied","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/alias/driver.go","lineNumber":185,"sourceCode":"\t\treturn errs.PermissionDenied\n\t}\n\treqPath, err := d.getReqPath(ctx, srcObj, false)\n\tif err == nil {\n\t\treturn fs.Rename(ctx, *reqPath, newName)\n\t}\n\tif errs.IsNotImplement(err) {\n\t\treturn errors.New(\"same-name files cannot be Rename\")\n\t}\n\treturn err\n}\n\nfunc (d *Alias) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {\n\tif !d.Writable {\n\t\treturn errs.PermissionDenied\n\t}\n\tsrcPath, err := d.getReqPath(ctx, srcObj, false)\n\tif errs.IsNotImplement(err) {\n\t\treturn errors.New(\"same-name files cannot be copied\")\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tdstPath, err := d.getReqPath(ctx, dstDir, true)\n\tif errs.IsNotImplement(err) {\n\t\treturn errors.New(\"same-name dirs cannot be copied to\")\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = fs.Copy(ctx, *srcPath, *dstPath)\n\treturn err\n}\n\nfunc (d *Alias) Remove(ctx context.Context, obj model.Obj) error {\n\tif !d.Writable {\n\t\treturn errs.PermissionDenied","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/alias/driver.go#L167-L203","documentation":"Returned by Alias.Copy when the SOURCE file cannot be uniquely resolved: getReqPath(srcObj) fails with errs.NotImplement because ProtectSameName is on and the source exists in multiple destinations mapped under one alias key. The driver will not guess which copy to read from.","triggerScenarios":"ProtectSameName=true; alias key with 2+ destinations both containing the source file; Copy(srcObj, dstDir) called through the alias mount.","commonSituations":"Copy operations out of a merged mirror mount; deduplicated backups where the same relative path exists on several storages under one alias name.","solutions":["Copy from a uniquely-keyed alias or directly from the underlying mount","Disable ProtectSameName (first-resolved destination wins)","Keep one authoritative copy and mount the others under different keys","Script the copy per mirror explicitly when you truly want all copies"],"exampleFix":"// before\nfs.Copy(ctx, \"/alias/data/file.bin\", \"/alias/backup\")\n\n// after\nfs.Copy(ctx, \"/netdisk_a/docs/file.bin\", \"/netdisk_a/backup\")","handlingStrategy":"validation","validationCode":"// Ensure single-source resolution before copying through alias\nif len(d.pathMap[rootOf(src)]) > 1 && d.ProtectSameName {\n    return errors.New(\"source mirrored; copy from a concrete mount\")\n}","typeGuard":"// Go\nfunc isSameNameErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"same-name\")\n}","tryCatchPattern":"if err := d.Copy(ctx, src, dst); isSameNameErr(err) {\n    // copy from /netdisk_a/... explicitly\n} else if err != nil { return err }","preventionTips":["Keep one authoritative copy per alias key for copy sources","Expose each mirror under its own key","Log which destination a copy came from to detect mirror divergence early"],"tags":["alias","protect-same-name","copy","source-ambiguity"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}