AlistGo/alist · error

move file failed: %w

Error message

move file failed: %w

What it means

The Darkibox driver's Move failed at the remote /file/move API call. The %w wraps the callAPI error, which can be an HTTP status error, a provider status/msg error, or a decode failure. The file was not moved.

Source

Thrown at drivers/darkibox/driver.go:194

	if srcObj.IsDir() {
		return nil, errs.NotImplement
	}

	fileCode := fileCodeFromObjID(srcObj.GetID())
	if fileCode == "" {
		return nil, fmt.Errorf("empty file code")
	}

	dstFolderID := d.RootFolderID
	if dstDir.GetID() != "" {
		dstFolderID = folderIDFromObjID(dstDir.GetID())
	}

	if err := d.callAPI(ctx, "/file/move", map[string]string{
		"file_code": fileCode,
		"to_folder": fldIDStr(dstFolderID),
	}, nil); err != nil {
		return nil, fmt.Errorf("move file failed: %w", err)
	}

	return &model.Object{
		ID:       srcObj.GetID(),
		Name:     srcObj.GetName(),
		Size:     srcObj.GetSize(),
		Modified: srcObj.ModTime(),
		IsFolder: false,
	}, nil
}

func (d *Darkibox) Rename(ctx context.Context, srcObj model.Obj, newName string) (model.Obj, error) {
	return nil, errs.NotImplement
}

func (d *Darkibox) Copy(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
	return nil, errs.NotImplement
}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Check the wrapped error text — 'darkibox api error: status=... msg=...' gives the provider's reason; address auth/permission/quota accordingly
  2. Refresh the destination listing to confirm dstDir's encoded folder ID still exists, then retry
  3. Test a move to the root folder to isolate destination-specific permission problems

Example fix

// before
if err := d.callAPI(ctx, "/file/move", params, nil); err != nil {
	return nil, fmt.Errorf("move file failed: %w", err)
}
// after — include file code and destination in the message
if err := d.callAPI(ctx, "/file/move", params, nil); err != nil {
	return nil, fmt.Errorf("move file %s to folder %s failed: %w", fileCode, dstFolderID, err)
}
Defensive patterns

Strategy: retry

Validate before calling

if dstDir.GetID() != "" {
	if _, err := d.Get(ctx, dstDir); err != nil {
		return nil, fmt.Errorf("destination not reachable: %w", err)
	}
}

Type guard

func isMovableFile(obj model.Obj) bool {
	return !obj.IsDir() && fileCodeFromObjID(obj.GetID()) != ""
}

Try / catch

if err != nil && strings.Contains(err.Error(), "move file failed") {
	if isTransientAPIError(err) { // 5xx/429 in chain
		backoffAndRetry()
	}
}

Prevention

When it happens

Trigger: POST /file/move with a valid file_code but: destination folder ID doesn't exist, API key lacks permission for the target folder, provider-side rate limit, or network failure to apiBase.

Common situations: Moving to a folder deleted since the listing was made; wrong API key scope; provider outage; destination resolved to root while the key cannot write to root.

Related errors


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