List all R2 objects bucket-wide so new folders are picked up automatically; v2.0.38
Publish Container / docker (push) Successful in 13m50s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-09-18 12:06:10 -04:00
1 parent f525e7e784
commit 4e6449f3a7
2 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "siteforge", "name": "siteforge",
"private": true, "private": true,
"version": "2.0.37", "version": "2.0.38",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
+4 -4
View File
@@ -967,17 +967,17 @@ export async function listUploadedAssets() {
const { isR2Configured, listR2Objects } = await import('./r2.js') const { isR2Configured, listR2Objects } = await import('./r2.js')
const { R2_PUBLIC_URL } = await import('./config.js') const { R2_PUBLIC_URL } = await import('./config.js')
if (isR2Configured()) { if (isR2Configured()) {
const ALL_FOLDERS = ['uploads', 'images', 'guides', 'finished'] const objects = await listR2Objects('')
const objects = (await Promise.all(ALL_FOLDERS.map(f => listR2Objects(`${f}/`)))).flat()
r2Assets = objects r2Assets = objects
.filter(obj => /\.(png|jpe?g|webp|gif|pdf|docx?)$/i.test(obj.Key)) .filter(obj => /\.(png|jpe?g|webp|gif|pdf|docx?)$/i.test(obj.Key))
.map(obj => { .map(obj => {
const filename = obj.Key.split('/').pop() const parts = obj.Key.split('/')
const filename = parts.pop()
const folder = parts.length > 0 ? parts[0] : ''
const entry = metadata[filename] const entry = metadata[filename]
const tags = Array.isArray(entry) const tags = Array.isArray(entry)
? entry.filter(t => typeof t === 'string') ? entry.filter(t => typeof t === 'string')
: Array.isArray(entry?.tags) ? entry.tags.filter(t => typeof t === 'string') : [] : Array.isArray(entry?.tags) ? entry.tags.filter(t => typeof t === 'string') : []
const folder = obj.Key.split('/')[0]
return { return {
filename, filename,
url: `${R2_PUBLIC_URL}/${obj.Key}`, url: `${R2_PUBLIC_URL}/${obj.Key}`,