[bugfix] Fix Load Image (from Outputs) node failing on macOS

Filter out .DS_Store and placeholder files from remote widget file lists.

On macOS, the .DS_Store file (a hidden system file created by Finder) was
being included in the output folder file list. When the "Load Image (from
Outputs)" node refreshed, it would select .DS_Store as the first file,
causing the image preview to fail with an error since .DS_Store is not a
valid image file.

This fix filters out .DS_Store and the _output_images_will_be_put_here
placeholder file from file lists returned by remote widget API calls.
This commit is contained in:
Johnpaul
2025-12-06 03:56:18 +01:00
parent ec1a7f1da4
commit 61c566e585

View File

@@ -65,6 +65,19 @@ const isBackingOff = (entry: CacheEntry<unknown> | undefined) =>
entry?.lastErrorTime &&
Date.now() - entry.lastErrorTime < getBackoff(entry.retryCount || 0)
// Filter out invalid files like .DS_Store
const filterFileList = <T>(data: T): T => {
if (!Array.isArray(data)) return data
return data.filter((item) => {
if (typeof item !== 'string') return true
const basename = item.split('/').pop() ?? ''
if (['_output_images_will_be_put_here', '.DS_Store'].includes(basename)) {
return false
}
return true
}) as T
}
const fetchData = async (
config: RemoteWidgetConfig,
controller: AbortController
@@ -80,7 +93,8 @@ const fetchData = async (
...authHeaders
})
return response_key ? res.data[response_key] : res.data
const data = response_key ? res.data[response_key] : res.data
return filterFileList(data)
}
export function useRemoteWidget<