1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

fix(server): dot files (#4625)

This commit is contained in:
Jason Rasmussen 2023-10-24 12:08:18 -04:00 committed by GitHub
parent 3e3598fd92
commit 5921ec9a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -125,7 +125,12 @@ export class AuditService {
const fullPath = (filename: string) => resolve(filename);
const hasFile = (items: Set<string>, filename: string) => items.has(filename) || items.has(fullPath(filename));
const crawl = async (folder: StorageFolder) =>
new Set(await this.storageRepository.crawl({ pathsToCrawl: [StorageCore.getBaseFolder(folder)] }));
new Set(
await this.storageRepository.crawl({
includeHidden: true,
pathsToCrawl: [StorageCore.getBaseFolder(folder)],
}),
);
const uploadFiles = await crawl(StorageFolder.UPLOAD);
const libraryFiles = await crawl(StorageFolder.LIBRARY);

View File

@ -25,7 +25,7 @@ import {
NotFoundException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Response as Res } from 'express';
import { Response as Res, Response } from 'express';
import { constants } from 'fs';
import fs from 'fs/promises';
import path from 'path';
@ -52,6 +52,9 @@ import { CheckExistingAssetsResponseDto } from './response-dto/check-existing-as
import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto';
import { CuratedObjectsResponseDto } from './response-dto/curated-objects-response.dto';
type SendFile = Parameters<Response['sendFile']>;
type SendFileOptions = SendFile[1];
@Injectable()
export class AssetService {
readonly logger = new Logger(AssetService.name);
@ -436,7 +439,10 @@ export class AssetService {
private async sendFile(res: Res, filepath: string): Promise<void> {
await fs.access(filepath, constants.R_OK);
const options = path.isAbsolute(filepath) ? {} : { root: process.cwd() };
const options: SendFileOptions = { dotfiles: 'allow' };
if (!path.isAbsolute(filepath)) {
options.root = process.cwd();
}
res.set('Cache-Control', 'private, max-age=86400, no-transform');
res.header('Content-Type', mimeTypes.lookup(filepath));

View File

@ -117,7 +117,7 @@ export class FilesystemProvider implements IStorageRepository {
}
crawl(crawlOptions: CrawlOptionsDto): Promise<string[]> {
const { pathsToCrawl, exclusionPatterns } = crawlOptions;
const { pathsToCrawl, exclusionPatterns, includeHidden } = crawlOptions;
if (!pathsToCrawl) {
return Promise.resolve([]);
}
@ -129,6 +129,7 @@ export class FilesystemProvider implements IStorageRepository {
absolute: true,
nocase: true,
nodir: true,
dot: includeHidden,
ignore: exclusionPatterns,
});
}