AlistGo/alist · warning

failed to generate temp-file name: too many retries

Error message

failed to generate temp-file name: too many retries

What it means

This error is thrown by the temp-file name generator in internal/fs/archive.go after 10000 attempts to find an unused name in TempDir all collided. Each attempt joins a numeric prefix with a random uint32 and stats the path; a miss returns immediately, so 10000 consecutive existing paths is a pathological state, practically only possible when the temp directory holds an enormous number of same-prefix files.

Source

Thrown at internal/fs/archive.go:284

		return "", err
	}
	return newPath, nil
}

func genTempFileName(prefix string) (string, error) {
	retry := 0
	for retry < 10000 {
		newPath := stdpath.Join(conf.Conf.TempDir, prefix+strconv.FormatUint(uint64(rand.Uint32()), 10))
		if _, err := os.Stat(newPath); err != nil {
			if os.IsNotExist(err) {
				return newPath, nil
			} else {
				return "", err
			}
		}
		retry++
	}
	return "", errors.New("failed to generate temp-file name: too many retries")
}

type archiveContentUploadTaskManagerType struct {
	*tache.Manager[*ArchiveContentUploadTask]
}

func (m *archiveContentUploadTaskManagerType) Remove(id string) {
	if t, ok := m.GetByID(id); ok {
		t.deleteSrcFile()
		m.Manager.Remove(id)
	}
}

func (m *archiveContentUploadTaskManagerType) RemoveAll() {
	tasks := m.GetAll()
	for _, t := range tasks {
		m.Remove(t.GetID())
	}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Clear stale files out of the configured TempDir (conf.Conf.TempDir) and ensure periodic cleanup of temp files runs
  2. Point TempDir at a dedicated, empty directory on a volume with free space
  3. If it recurs, audit the archive task manager for tasks that never delete their scratch files (see deleteSrcFile) and fix the leak
  4. Restart the service after cleaning so paths are re-stat'ed against the trimmed directory
Defensive patterns

Strategy: fallback

Validate before calling

// before archive ops, ensure TempDir is usable and not bloated
if info, err := os.Stat(conf.Conf.TempDir); err != nil || !info.IsDir() {
    return fmt.Errorf("temp dir %s unavailable", conf.Conf.TempDir)
}

Type guard

func isTempNameRetryExhausted(err error) bool {
    return err != nil && strings.Contains(err.Error(), "too many retries")
}

Try / catch

p, err := tempName(prefix)
if isTempNameRetryExhausted(err) {
    // fall back to a mkstemp-style name in a fresh subdir; alert ops to clean TempDir
}

Prevention

When it happens

Trigger: Repeated archive operations (extraction/upload staging) in the same TempDir leaving a huge number of residue files with the same prefix; practically unreachable on a healthy system. Any call creating a scratch file for archive content upload can reach the retry cap.

Common situations: TempDir never cleaned and long-running instances accumulating staging files; TempDir misconfigured to a directory with unrelated files matching the prefix pattern; disk-cleanup jobs disabled. Realistically near-impossible and indicates a housekeeping defect rather than bad luck.

Related errors


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