Skip to content

Commit b7a6fe5

Browse files
committed
small table rename bug, files updates not persisting
1 parent 8abe717 commit b7a6fe5

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

apps/sim/app/api/files/serve/[...path]/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ async function handleLocalFile(filename: string, userId: string): Promise<NextRe
111111
buffer: fileBuffer,
112112
contentType,
113113
filename,
114+
cacheControl: contextParam === 'workspace' ? 'private, no-cache, must-revalidate' : undefined,
114115
})
115116
} catch (error) {
116117
logger.error('Error reading local file:', error)
@@ -172,6 +173,7 @@ async function handleCloudProxy(
172173
buffer: fileBuffer,
173174
contentType,
174175
filename: originalFilename,
176+
cacheControl: context === 'workspace' ? 'private, no-cache, must-revalidate' : undefined,
175177
})
176178
} catch (error) {
177179
logger.error('Error downloading from cloud storage:', error)

apps/sim/app/api/files/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface FileResponse {
2121
buffer: Buffer
2222
contentType: string
2323
filename: string
24+
cacheControl?: string
2425
}
2526

2627
export class FileNotFoundError extends Error {
@@ -256,7 +257,7 @@ export function createFileResponse(file: FileResponse): NextResponse {
256257
headers: {
257258
'Content-Type': contentType,
258259
'Content-Disposition': `${disposition}; ${encodeFilenameForHeader(file.filename)}`,
259-
'Cache-Control': 'public, max-age=31536000',
260+
'Cache-Control': file.cacheControl || 'public, max-age=31536000',
260261
'X-Content-Type-Options': 'nosniff',
261262
'Content-Security-Policy': "default-src 'none'; style-src 'unsafe-inline'; sandbox;",
262263
},

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/table.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ export function Table({
540540
if (!el) return
541541

542542
const handleKeyDown = (e: KeyboardEvent) => {
543+
const tag = (e.target as HTMLElement).tagName
544+
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return
545+
543546
const anchor = selectionAnchorRef.current
544547
if (!anchor || editingCellRef.current || editingEmptyCellRef.current) return
545548

apps/sim/hooks/queries/workspace-files.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export function useWorkspaceFiles(workspaceId: string) {
6262
* Fetch file content as text via the serve URL
6363
*/
6464
async function fetchWorkspaceFileContent(key: string, signal?: AbortSignal): Promise<string> {
65-
const serveUrl = `/api/files/serve/${encodeURIComponent(key)}?context=workspace`
66-
const response = await fetch(serveUrl, { signal })
65+
const serveUrl = `/api/files/serve/${encodeURIComponent(key)}?context=workspace&t=${Date.now()}`
66+
const response = await fetch(serveUrl, { signal, cache: 'no-store' })
6767

6868
if (!response.ok) {
6969
throw new Error('Failed to fetch file content')

0 commit comments

Comments
 (0)