AlistGo/alist · error

same-name dirs cannot make sub-dir

Error message

same-name dirs cannot make sub-dir

What it means

Returned by Alias.MakeDir when getReqPath fails with errs.NotImplement. Per drivers/alias/util.go:130, that happens when ProtectSameName is enabled and the parent path resolves to existing objects in MORE THAN ONE destination mapped under the same alias name — the driver cannot decide which underlying storage should receive the new sub-directory, so it refuses.

Source

Thrown at drivers/alias/driver.go:139

					link.PartSize = d.DownloadPartSize * utils.KB
				}
			}
			return link, nil
		}
	}
	return nil, errs.ObjectNotFound
}

func (d *Alias) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
	if !d.Writable {
		return errs.PermissionDenied
	}
	reqPath, err := d.getReqPath(ctx, parentDir, true)
	if err == nil {
		return fs.MakeDir(ctx, stdpath.Join(*reqPath, dirName))
	}
	if errs.IsNotImplement(err) {
		return errors.New("same-name dirs cannot make sub-dir")
	}
	return err
}

func (d *Alias) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
	if !d.Writable {
		return errs.PermissionDenied
	}
	srcPath, err := d.getReqPath(ctx, srcObj, false)
	if errs.IsNotImplement(err) {
		return errors.New("same-name files cannot be moved")
	}
	if err != nil {
		return err
	}
	dstPath, err := d.getReqPath(ctx, dstDir, true)
	if errs.IsNotImplement(err) {
		return errors.New("same-name dirs cannot be moved to")

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Give each destination a unique alias key in Paths (split 'data' into 'data1', 'data2') so targets are unambiguous
  2. Turn off ProtectSameName (accepts first destination that resolves — only if data loss to a 'wrong' backend is acceptable)
  3. Perform the mkdir directly on the underlying storage mount instead of through the alias
  4. Remove one of the duplicate underlying directories so only one destination resolves

Example fix

# before — same alias key twice, ambiguous with ProtectSameName
data: /netdisk_a/docs
data: /netdisk_b/docs

# after — unique keys per destination
data_a: /netdisk_a/docs
data_b: /netdisk_b/docs
Defensive patterns

Strategy: validation

Validate before calling

// Reject ambiguous multi-destination keys at setup time when ProtectSameName is on
keys := map[string]int{}
for _, l := range strings.Split(paths, "\n") {
    l = strings.TrimSpace(l)
    if l == "" { continue }
    k, _ := getPair(l)
    keys[k]++
}
for k, n := range keys {
    if n > 1 && protectSameName {
        return fmt.Errorf("alias key %q maps %d destinations; write ops on it will fail with ProtectSameName", k, n)
    }
}

Type guard

// Go
func isSameNameErr(err error) bool {
    return err != nil && strings.Contains(err.Error(), "same-name")
}

Try / catch

if err := d.MakeDir(ctx, parent, name); err != nil {
    if isSameNameErr(err) {
        // route the operation to a concrete underlying storage instead
    }
    return err
}

Prevention

When it happens

Trigger: ProtectSameName=true in the Addition, two or more lines in Paths sharing the same alias key (e.g. 'data: /a/dir' and 'data: /b/dir'), and the parent directory existing in both /a/dir and /b/dir; then mkdir is invoked on that aliased parent.

Common situations: Users mount several storages under one merged name for redundancy, enable ProtectSameName to avoid writing to the wrong one, then attempt create/move/copy operations that must target exactly one backend.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/354114d3c755c44a. Report an issue: GitHub.