Skip to content

[BUG] server: cannot access asset resources #4465

@waclaw66

Description

@waclaw66

The bug

While debugging immich-server I've discovered that many filesystem routines access assets by relative path only.

await fs.access(filepath, constants.R_OK);

In the above example an asset is checked for availability by the relative path like upload/thumbs/82b637ca-7ad6-43cd-a15d-aad029fc87f2/89/36/8936b4dc-a251-43ba-992e-70a171bc8b05.jpeg only. If the server process runs from different directory than root of the assets library (my case, because of starting debug manually by npm run start:debug immich from server source directory), assets cannot be accessed by relative path. In the next step a file is read with the full path, however library root is taken from the current dir of the server process (why??)...
const options = path.isAbsolute(filepath) ? {} : { root: process.cwd() };

Those relative paths should be refactored to use the environment variable UPLOAD_LOCATION as library root to avoid having to run the server process from the library directory.

The OS that Immich Server is running on

Fedora 38

Version of Immich Server

v1.81.1

Version of Immich Mobile App

not relevant

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

not using Docker

Your .env content

UPLOAD_LOCATION=/var/lib/immich/upload

Reproduction steps

not relevant

Additional information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions