fix(admin/exports): Lightroom TXT export joins with comma + drops extension (#623)
The PhotoExportMenu's TXT format advertises "Simple text list for Lightroom search" but emitted newline-separated filenames WITH `.jpg`. Lightroom's filename search wants a comma-separated one-liner, and the gallery JPEGs may correspond to RAW files in the catalog — so the search has to match on the stem only. The frontend now passes `separator: 'comma'` + `include_extension: false` for the TXT format specifically. The backend gains an `include_extension` option (defaulting to true so direct API consumers don't break), and the comma case joins without a trailing space (the form Lightroom expects). Unit test pins the Lightroom-mode output AND the backward-compatible default for any direct API caller. CSV / XMP / JSON exports are unchanged.
This commit is contained in:
@@ -81,21 +81,36 @@ class PhotoExportService {
|
||||
|
||||
/**
|
||||
* Export as plain text filename list
|
||||
*
|
||||
* include_extension defaults to true for backward compatibility with any
|
||||
* direct API consumer. The admin UI sets it to false for the Lightroom
|
||||
* search use case — the gallery JPEGs may correspond to RAW files in the
|
||||
* photographer's catalog, so the search has to match on the stem only.
|
||||
*
|
||||
* The comma separator joins without a space, the form Lightroom's filename
|
||||
* search expects (per issue #623).
|
||||
*/
|
||||
exportAsTxt(photos, options = {}) {
|
||||
const { filename_format = 'original', separator = 'newline' } = options;
|
||||
const {
|
||||
filename_format = 'original',
|
||||
separator = 'newline',
|
||||
include_extension = true,
|
||||
} = options;
|
||||
|
||||
const filenames = photos.map(photo =>
|
||||
filename_format === 'original' ? (photo.original_filename || photo.filename) : photo.filename
|
||||
);
|
||||
const filenames = photos.map(photo => {
|
||||
const name = filename_format === 'original'
|
||||
? (photo.original_filename || photo.filename)
|
||||
: photo.filename;
|
||||
return include_extension ? name : path.parse(name).name;
|
||||
});
|
||||
|
||||
let content;
|
||||
switch (separator) {
|
||||
case 'comma':
|
||||
content = filenames.join(', ');
|
||||
content = filenames.join(',');
|
||||
break;
|
||||
case 'semicolon':
|
||||
content = filenames.join('; ');
|
||||
content = filenames.join(';');
|
||||
break;
|
||||
default:
|
||||
content = filenames.join('\n');
|
||||
|
||||
Reference in New Issue
Block a user