mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix(server): support special characters in library paths (#9385)
Support special characters in library paths
This commit is contained in:
parent
a05c990718
commit
4e6aeeda4d
2 changed files with 12 additions and 13 deletions
|
@ -76,17 +76,6 @@ const tests: Test[] = [
|
||||||
'/albums/image3.jpg': true,
|
'/albums/image3.jpg': true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
test: 'should support globbing paths',
|
|
||||||
options: {
|
|
||||||
pathsToCrawl: ['/photos*'],
|
|
||||||
},
|
|
||||||
files: {
|
|
||||||
'/photos1/image1.jpg': true,
|
|
||||||
'/photos2/image2.jpg': true,
|
|
||||||
'/images/image3.jpg': false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
test: 'should crawl a single path without trailing slash',
|
test: 'should crawl a single path without trailing slash',
|
||||||
options: {
|
options: {
|
||||||
|
@ -179,6 +168,15 @@ const tests: Test[] = [
|
||||||
[`/photos/3.jpg`]: false,
|
[`/photos/3.jpg`]: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: 'should support special characters in paths',
|
||||||
|
options: {
|
||||||
|
pathsToCrawl: ['/photos (new)'],
|
||||||
|
},
|
||||||
|
files: {
|
||||||
|
['/photos (new)/1.jpg']: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
describe(StorageRepository.name, () => {
|
describe(StorageRepository.name, () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import archiver from 'archiver';
|
import archiver from 'archiver';
|
||||||
import chokidar, { WatchOptions } from 'chokidar';
|
import chokidar, { WatchOptions } from 'chokidar';
|
||||||
import { glob, globStream } from 'fast-glob';
|
import { escapePath, glob, globStream } from 'fast-glob';
|
||||||
import { constants, createReadStream, existsSync, mkdirSync } from 'node:fs';
|
import { constants, createReadStream, existsSync, mkdirSync } from 'node:fs';
|
||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
@ -186,7 +186,8 @@ export class StorageRepository implements IStorageRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
private asGlob(pathsToCrawl: string[]): string {
|
private asGlob(pathsToCrawl: string[]): string {
|
||||||
const base = pathsToCrawl.length === 1 ? pathsToCrawl[0] : `{${pathsToCrawl.join(',')}}`;
|
const escapedPaths = pathsToCrawl.map((path) => escapePath(path));
|
||||||
|
const base = escapedPaths.length === 1 ? escapedPaths[0] : `{${escapedPaths.join(',')}}`;
|
||||||
const extensions = `*{${mimeTypes.getSupportedFileExtensions().join(',')}}`;
|
const extensions = `*{${mimeTypes.getSupportedFileExtensions().join(',')}}`;
|
||||||
return `${base}/**/${extensions}`;
|
return `${base}/**/${extensions}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue