Skip to content

Commit 2afc014

Browse files
Add ETag to existing empty folder listings, skip ETag for non-existent folders
Existing folders with no entries get their real ETag (or "empty" fallback). Non-existent folders intentionally omit ETag to prevent RS clients from getting stuck in a 304 loop that skips push logic.
1 parent 107c500 commit 2afc014

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/remotestorage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export async function remoteStoragePlugin (fastify, options = {}) {
100100
const info = await storage.stat(storagePath)
101101

102102
// Non-existent folder → return empty listing (RS spec: clients expect 200 to start writing)
103+
// No ETag — forces RS clients to process the folder each sync cycle (304 would skip push logic)
103104
if (!info && storagePath.endsWith('/')) {
104105
return reply
105106
.header('Content-Type', 'application/ld+json')
@@ -126,6 +127,7 @@ export async function remoteStoragePlugin (fastify, options = {}) {
126127
if (!entries) {
127128
return reply
128129
.header('Content-Type', 'application/ld+json')
130+
.header('ETag', info.etag || '"empty"')
129131
.header('Cache-Control', 'no-cache')
130132
.send({
131133
'@context': 'http://remotestorage.io/spec/folder-description',

0 commit comments

Comments
 (0)