\App\Console\CommandsBackfillFileHash

历史文件 file_hash 回填命令

职责:扫描正常状态且 file_hash 为空(NULL/空串)的历史文件,按当前 file.hash_algo 配置流式哈希回填,供重复文件聚族(duplicates/overview)。

┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 命令签名与说明 $signature / $description 分区 2 · 执行入口 handle └────────────────────────────────────────────────────────────┘

Summary

Methods
Properties
Constants
handle()
No public properties found
No constants found
No protected methods found
$signature
$description
N/A
No private methods found
No private properties found
N/A

Properties

$signature

$signature

命令签名:files:backfill-hash,--dry-run 只统计不写库

$description

$description

命令说明

Methods

handle()

handle(\App\Services\Admin\ConfigService  $config) : int

执行回填。

流程:① 读 file.hash_algo 配置(none=哈希已关闭,警告退出不干活) ② chunkById(200) 扫正常且 hash 为空的文件,物理缺失计 missing 跳过 ③ 流式哈希(hash_init + hash_update_stream)逐文件回填 ——写库走查询构建器 update(不触发模型事件,避免每行全量失效抖动), 故结尾统一 forget 台账三缓存(overview/duplicates/dangling-refs) ④ 输出汇总;--dry-run 只统计不写库

Parameters

\App\Services\Admin\ConfigService $config

Returns

int —