Repository navigation
[Bug]: Git storage sync fails with treeFolderDuplicate during asset adoption when directory matches existing path #8184
DescriptionWhen using the Git storage target in Wiki.js v3, initiating a synchronization ( During Steps to Reproduce
Expected BehaviorStorage synchronization should be idempotent. If a folder or tree node already exists at a given path in Actual BehaviorThe sync job fails and rolls back with the following stack trace: Root Cause Analysis
Applied FixIn const existing = await WIKI.db
.select({ id: treeTable.id, type: treeTable.type })
.from(treeTable)
.where(
and(
eq(treeTable.siteId, siteId),
eq(treeTable.locale, effectiveLocale),
eq(treeTable.folderPath, path),
eq(treeTable.fileName, name),
ne(treeTable.type, 'page')
)
)
.limit(1)
if (existing.length > 0) {
if (existing[0].type === 'folder') {
return ((await this.getFolderById(existing[0].id)) ?? existing[0]) as TreeRow
}
throw new CustomError(
'treeFolderDuplicate',
existing[0].type === 'folder'
? 'A folder with this path name already exists.'
: 'A file with this path name already exists here.',
409
)
}Verification & Result
Helped by Gemini. |
Fixed via e213715. Will land in next release.
However, your suggested fix actually makes things silently worst, as it doesn't address the actual mismatch between the input and what's already there.