Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place

Handle empty tier metadata file

+12
+12
packages/@wispplace/tiered-storage/src/tiers/DiskStorageTier.ts
··· 208 208 readFile(metaPath, 'utf-8'), 209 209 ]); 210 210 211 + if (!metaContent.trim()) { 212 + return null; 213 + } 211 214 const metadata = JSON.parse(metaContent) as StorageMetadata; 212 215 213 216 // Convert date strings back to Date objects ··· 221 224 } catch (error) { 222 225 const code = (error as NodeJS.ErrnoException).code; 223 226 if (code === 'ENOENT' || code === 'ENOTDIR') { 227 + return null; 228 + } 229 + if (error instanceof SyntaxError) { 224 230 return null; 225 231 } 226 232 throw error; ··· 244 250 try { 245 251 // Read metadata first to verify file exists 246 252 const metaContent = await readFile(metaPath, 'utf-8'); 253 + if (!metaContent.trim()) { 254 + return null; 255 + } 247 256 const metadata = JSON.parse(metaContent) as StorageMetadata; 248 257 249 258 // Convert date strings back to Date objects ··· 260 269 } catch (error) { 261 270 const code = (error as NodeJS.ErrnoException).code; 262 271 if (code === 'ENOENT' || code === 'ENOTDIR') { 272 + return null; 273 + } 274 + if (error instanceof SyntaxError) { 263 275 return null; 264 276 } 265 277 throw error;