AlistGo/alist · warning

file not found by hash

Error message

file not found by hash

What it means

The hash lookup succeeded (Result=Success) but the FileInfo array came back empty — MediaFire accepted the query and reports zero files matching the hash. It is the empty-result counterpart to the file-search failure and means the file is definitively not in this account.

Source

Thrown at drivers/mediafire/util.go:621

func (d *Mediafire) getFileByHash(_ context.Context, hash string) (*model.ObjThumb, error) {
	query := map[string]string{
		"session_token":   d.SessionToken,
		"response_format": "json",
		"hash":            hash,
	}

	var resp MediafireFileSearchResponse
	_, err := d.postForm("/file/get_info.php", query, &resp)
	if err != nil {
		return nil, err
	}

	if resp.Response.Result != "Success" {
		return nil, fmt.Errorf("MediaFire file search failed: %s", resp.Response.Result)
	}

	if len(resp.Response.FileInfo) == 0 {
		return nil, fmt.Errorf("file not found by hash")
	}

	file := resp.Response.FileInfo[0]
	return d.fileToObj(file), nil
}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Map this to a standard not-found error and handle it as the normal 'file absent' case
  2. If the file was just uploaded, wait briefly and retry once — indexing is asynchronous
  3. Verify the hash matches the algorithm MediaFire uses for file fingerprints before relying on it
  4. Use folder listing by name as a fallback verification path

Example fix

// before
if len(resp.Response.FileInfo) == 0 {
    return nil, fmt.Errorf("file not found by hash")
}

// after
if len(resp.Response.FileInfo) == 0 {
    return nil, errs.ObjectNotFound // standard, typed not-found for callers
}
Defensive patterns

Strategy: validation

Validate before calling

if hash == "" { return errors.New("empty hash") }
// post-upload: brief retry window for indexing
if justUploaded { time.Sleep(2 * time.Second) }

Try / catch

// Empty-result is a clean not-found
file, err := d.getFileByHash(ctx, hash)
if err != nil && strings.Contains(err.Error(), "file not found by hash") {
    return nil, errs.ObjectNotFound
}

Prevention

When it happens

Trigger: Any getFileByHash call where no file with that SHA-1/fingerprint hash exists in the account; hash of a file still mid-upload so not yet indexed; querying immediately after upload before indexing completes.

Common situations: Dedup checks before upload (expected empty); post-upload verification racing MediaFire's indexing; verifying whether a poll-failed upload actually landed (it did not).

Related errors


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