Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
fix(storage): send Content-Length for local files so viewer progress advances
Alexander Sysoeve91b2858f44e
diff --git a/app/components/photo/LoadingIndicator.vue b/app/components/photo/LoadingIndicator.vueindex c8fac887..4d5a1fef 100644--- a/app/components/photo/LoadingIndicator.vue+++ b/app/components/photo/LoadingIndicator.vue@@ -153,7 +153,10 @@ const loadingVariants = {: $t('viewer.photoload.loading')}}</p>- <span class="text-xs text-white/60 tabular-nums">+ <span+ v-if="loadingState.bytesTotal > 0"+ class="text-xs text-white/60 tabular-nums"+ >{{ Math.round(loadingState.progress) }}%</span></div>@@ -164,6 +167,12 @@ const loadingVariants = {{{ (loadingState.bytesLoaded / 1024 / 1024).toFixed(1) }}MB /{{ (loadingState.bytesTotal / 1024 / 1024).toFixed(1) }}MB</p>+ <p+ v-else-if="loadingState.bytesLoaded > 0"+ class="text-xs text-white/70 tabular-nums"+ >+ {{ (loadingState.bytesLoaded / 1024 / 1024).toFixed(1) }}MB+ </p></template></div></div>diff --git a/app/libs/image-loader-manager.ts b/app/libs/image-loader-manager.tsindex 0d02605b..8e171296 100644--- a/app/libs/image-loader-manager.ts+++ b/app/libs/image-loader-manager.ts@@ -119,6 +119,15 @@ export class ImageLoaderManager {bytesLoaded: event.loaded,bytesTotal: event.total,})+ } else {+ // No Content-Length (e.g. chunked responses behind some proxies):+ // still surface the bytes received so the UI can show activity+ // instead of a frozen 0%.+ onUpdateLoadingState?.({+ progress: 0,+ bytesLoaded: event.loaded,+ bytesTotal: 0,+ })}}diff --git a/server/routes/storage/[...path].ts b/server/routes/storage/[...path].tsindex 60b2e858..e9509749 100644--- a/server/routes/storage/[...path].ts+++ b/server/routes/storage/[...path].ts@@ -60,8 +60,9 @@ export default defineEventHandler(async (event) => {throw createError({ statusCode: 400, statusMessage: 'Invalid path' })}+ let stat: Awaited<ReturnType<typeof fs.stat>>try {- const stat = await fs.stat(absolute)+ stat = await fs.stat(absolute)if (!stat.isFile()) {throw createError({ statusCode: 404, statusMessage: 'Not Found' })}@@ -112,6 +113,11 @@ export default defineEventHandler(async (event) => {throw createError({ statusCode: 404, statusMessage: 'Not Found' })}+ // Full-file response: advertise the size so browsers can compute download+ // progress (XHR `lengthComputable`). Without it Node falls back to chunked+ // transfer encoding and the viewer's progress stays at 0% (#191).+ setHeader(event, 'Accept-Ranges', 'bytes')+ setHeader(event, 'Content-Length', stat.size)const stream = createReadStream(absolute)return sendStream(event, stream)})