sync: re-link a local plugin when it was removed from the profile even if its hash is unchanged

This commit is contained in:
lyuksovannyy committed 2026-10-11 12:03:21 +00:00
1 parent 08202cad67
commit 5dff41a3d0
2 files changed
+8 -1

No files matched your search

+1 -1
View File
@@ -495,7 +495,7 @@ export function apply(ctx, config = {}) {
if (!sync.allowed(b.name, local)) { result.skipped.push(`${b.name} (local deny/allow)`); continue } if (!sync.allowed(b.name, local)) { result.skipped.push(`${b.name} (local deny/allow)`); continue }
try { try {
if (b.kind === 'local') { if (b.kind === 'local') {
if (prev[b.name]?.hash === b.hash) { next[b.name] = prev[b.name]; continue } if (prev[b.name]?.hash === b.hash && sync.isLinked(b.name, prev[b.name].dir)) { next[b.name] = prev[b.name]; continue }
const stream = mux.open('blob', { name: b.name }) const stream = mux.open('blob', { name: b.name })
const buf = await new Promise((resolve, reject) => { const buf = await new Promise((resolve, reject) => {
const parts = [] const parts = []
+7
View File
@@ -285,6 +285,13 @@ export function allowed(name, { allow = [], deny = [] } = {}) {
return true return true
} }
/** True when the profile still lists `name` as a bundle linked to `dir` (survives manual edits). */
export function isLinked(name, dir) {
const pkg = readJson(path.join(profileDir(), 'package.json'))
if (!pkg || !dir || !fs.existsSync(dir)) return false
return pkg.dependencies?.[name] === `link:${dir}` && (pkg.dsh?.profile?.bundles || []).includes(name)
}
/** Link-spec install of a local plugin dir into the profile (package.json + bundles list). */ /** Link-spec install of a local plugin dir into the profile (package.json + bundles list). */
export function linkLocalBundle(name, dir) { export function linkLocalBundle(name, dir) {
const prof = profileDir() const prof = profileDir()