mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:17:11 -05:00 
			
		
		
		
	fix(server): support import paths with special chars (#14856)
This commit is contained in:
		
							parent
							
								
									4bc2aa5451
								
							
						
					
					
						commit
						c3be74c450
					
				@ -403,6 +403,67 @@ describe('/libraries', () => {
 | 
			
		||||
      utils.removeImageFile(`${testAssetDir}/temp/folder} b/assetB.png`);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    const annoyingChars = [
 | 
			
		||||
      "'",
 | 
			
		||||
      '"',
 | 
			
		||||
      '`',
 | 
			
		||||
      '*',
 | 
			
		||||
      '{',
 | 
			
		||||
      '}',
 | 
			
		||||
      ',',
 | 
			
		||||
      '(',
 | 
			
		||||
      ')',
 | 
			
		||||
      '[',
 | 
			
		||||
      ']',
 | 
			
		||||
      '?',
 | 
			
		||||
      '!',
 | 
			
		||||
      '@',
 | 
			
		||||
      '#',
 | 
			
		||||
      '$',
 | 
			
		||||
      '%',
 | 
			
		||||
      '^',
 | 
			
		||||
      '&',
 | 
			
		||||
      '=',
 | 
			
		||||
      '+',
 | 
			
		||||
      '~',
 | 
			
		||||
      '|',
 | 
			
		||||
      '<',
 | 
			
		||||
      '>',
 | 
			
		||||
      ';',
 | 
			
		||||
      ':',
 | 
			
		||||
      '/', // We never got backslashes to work
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    it.each(annoyingChars)('should scan multiple import paths with %s', async (char) => {
 | 
			
		||||
      const library = await utils.createLibrary(admin.accessToken, {
 | 
			
		||||
        ownerId: admin.userId,
 | 
			
		||||
        importPaths: [`${testAssetDirInternal}/temp/folder${char}1`, `${testAssetDirInternal}/temp/folder${char}2`],
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      utils.createImageFile(`${testAssetDir}/temp/folder${char}1/asset1.png`);
 | 
			
		||||
      utils.createImageFile(`${testAssetDir}/temp/folder${char}2/asset2.png`);
 | 
			
		||||
 | 
			
		||||
      const { status } = await request(app)
 | 
			
		||||
        .post(`/libraries/${library.id}/scan`)
 | 
			
		||||
        .set('Authorization', `Bearer ${admin.accessToken}`)
 | 
			
		||||
        .send();
 | 
			
		||||
      expect(status).toBe(204);
 | 
			
		||||
 | 
			
		||||
      await utils.waitForQueueFinish(admin.accessToken, 'library');
 | 
			
		||||
 | 
			
		||||
      const { assets } = await utils.searchAssets(admin.accessToken, { libraryId: library.id });
 | 
			
		||||
 | 
			
		||||
      expect(assets.items).toEqual(
 | 
			
		||||
        expect.arrayContaining([
 | 
			
		||||
          expect.objectContaining({ originalPath: expect.stringContaining(`folder${char}1/asset1.png`) }),
 | 
			
		||||
          expect.objectContaining({ originalPath: expect.stringContaining(`folder${char}2/asset2.png`) }),
 | 
			
		||||
        ]),
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      utils.removeImageFile(`${testAssetDir}/temp/folder${char}1/asset1.png`);
 | 
			
		||||
      utils.removeImageFile(`${testAssetDir}/temp/folder${char}2/asset2.png`);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('should reimport a modified file', async () => {
 | 
			
		||||
      const library = await utils.createLibrary(admin.accessToken, {
 | 
			
		||||
        ownerId: admin.userId,
 | 
			
		||||
 | 
			
		||||
@ -214,7 +214,7 @@ export class StorageRepository implements IStorageRepository {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private asGlob(pathToCrawl: string): string {
 | 
			
		||||
    const escapedPath = escapePath(pathToCrawl);
 | 
			
		||||
    const escapedPath = escapePath(pathToCrawl).replaceAll('"', '["]').replaceAll("'", "[']").replaceAll('`', '[`]');
 | 
			
		||||
    const extensions = `*{${mimeTypes.getSupportedFileExtensions().join(',')}}`;
 | 
			
		||||
    return `${escapedPath}/**/${extensions}`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user