chore(deadcode): share plugin snapshot fingerprint · openclaw/openclaw@cba9c02
vincentkoc
·
2026-06-21
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -36,6 +36,7 @@ import {
|
36 | 36 | type PluginRegistrySnapshotSource, |
37 | 37 | } from "./plugin-registry.js"; |
38 | 38 | import { normalizePluginIdScope, serializePluginIdScope } from "./plugin-scope.js"; |
| 39 | +import { fileFingerprint } from "./plugin-snapshot-fingerprint.js"; |
39 | 40 | |
40 | 41 | type PluginMetadataSnapshotMemo = { |
41 | 42 | key: string; |
@@ -86,16 +87,6 @@ export type {
|
86 | 87 | ResolvePluginMetadataSnapshotParams, |
87 | 88 | } from "./plugin-metadata-snapshot.types.js"; |
88 | 89 | |
89 | | -function fileFingerprint(filePath: string): unknown { |
90 | | -try { |
91 | | -const stat = fs.statSync(filePath, { bigint: true }); |
92 | | -const kind = stat.isFile() ? "file" : stat.isDirectory() ? "dir" : "other"; |
93 | | -return [filePath, kind, stat.size.toString(), stat.mtimeNs.toString(), stat.ctimeNs.toString()]; |
94 | | -} catch { |
95 | | -return [filePath, "missing"]; |
96 | | -} |
97 | | -} |
98 | | - |
99 | 90 | function directoryChildPackageJsonFingerprint(directoryPath: string): unknown { |
100 | 91 | let entries: fs.Dirent[]; |
101 | 92 | try { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -35,6 +35,7 @@ import {
|
35 | 35 | } from "./installed-plugin-index.js"; |
36 | 36 | import { registerPluginMetadataProcessMemoLifecycleClear } from "./plugin-metadata-lifecycle.js"; |
37 | 37 | import type { PluginRegistrySnapshotSource } from "./plugin-registry-snapshot.types.js"; |
| 38 | +import { fileFingerprint } from "./plugin-snapshot-fingerprint.js"; |
38 | 39 | import { resolvePluginCacheInputs } from "./roots.js"; |
39 | 40 | |
40 | 41 | export type PluginRegistrySnapshot = InstalledPluginIndex; |
@@ -205,16 +206,6 @@ function directoryChildFingerprint(directoryPath: string): unknown {
|
205 | 206 | } |
206 | 207 | } |
207 | 208 | |
208 | | -function fileFingerprint(filePath: string): unknown { |
209 | | -try { |
210 | | -const stat = fs.statSync(filePath, { bigint: true }); |
211 | | -const kind = stat.isFile() ? "file" : stat.isDirectory() ? "dir" : "other"; |
212 | | -return [filePath, kind, stat.size.toString(), stat.mtimeNs.toString(), stat.ctimeNs.toString()]; |
213 | | -} catch { |
214 | | -return [filePath, "missing"]; |
215 | | -} |
216 | | -} |
217 | | - |
218 | 209 | function findPluginRegistrySnapshotMemo( |
219 | 210 | key: string | undefined, |
220 | 211 | ): PluginRegistrySnapshotResult | undefined { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import fs from "node:fs"; |
| 2 | + |
| 3 | +export function fileFingerprint(filePath: string): unknown { |
| 4 | +try { |
| 5 | +const stat = fs.statSync(filePath, { bigint: true }); |
| 6 | +const kind = stat.isFile() ? "file" : stat.isDirectory() ? "dir" : "other"; |
| 7 | +return [filePath, kind, stat.size.toString(), stat.mtimeNs.toString(), stat.ctimeNs.toString()]; |
| 8 | +} catch { |
| 9 | +return [filePath, "missing"]; |
| 10 | +} |
| 11 | +} |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。