@@ -150,18 +150,23 @@ async function _decompressGzip(blob) {
150150function exportData ( ) {
151151 document . getElementById ( 'settings-dropdown' ) . classList . remove ( 'open' ) ;
152152 if ( ! photos . length && ! albums . length ) { showToast ( 'No data to export' , 'error' ) ; return ; }
153+ const realPhotos = photos . filter ( p => ! p . isEmptyPin ) ;
154+ const emptyCount = photos . length - realPhotos . length ;
155+ if ( realPhotos . length === 0 ) { showToast ( 'No photos to export — only empty pins found' , 'error' ) ; return ; }
156+ if ( emptyCount > 0 ) showToast ( `Exporting ${ realPhotos . length } photo${ realPhotos . length !== 1 ?'s' :'' } (${ emptyCount } empty pin${ emptyCount !== 1 ?'s' :'' } excluded)` , 'info' ) ;
153157 showProg ( true ) ;
154158 updProg ( 5 , 'Preparing data...' ) ;
155159 // Defer the heavy work so the progress bar renders immediately
156160 setTimeout ( ( ) => _doExport ( ) , 50 ) ;
157161}
158162async function _doExport ( ) {
159- // Strip large binary fields — full-size images are stored on disk by serve.py,
160- // thumbnails are regenerated on import. Including them causes "Invalid string length"
161- // errors on large datasets (>512MB V8 string limit).
162- const exportPhotos = photos . map ( p => {
163+ // Replace base64 dataUrl with the server file path — full-size images live in
164+ // matrix-photos/ on disk. On import, the path is resolved back to a data URL.
165+ // This avoids "Invalid string length" errors on large datasets (>512MB V8 limit).
166+ const exportPhotos = photos . filter ( p => ! p . isEmptyPin ) . map ( p => {
163167 const { dataUrl, ...rest } = p ;
164- return rest ;
168+ const ext = ( dataUrl && dataUrl . match ( / d a t a : i m a g e \/ ( \w + ) / ) ?. [ 1 ] === 'png' ) ? 'png' : 'jpg' ;
169+ return { ...rest , dataUrl : `matrix-photos/${ p . id } .${ ext } ` } ;
165170 } ) ;
166171 const payload = { version : 1 , exportedAt : Date . now ( ) , photos : exportPhotos , albums, geoCodeCache : { ..._geoCodeCache } , geoCountryCache : { ..._geoCountryCache } } ;
167172 const json = JSON . stringify ( payload ) ;
0 commit comments