immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
44.56k stars 2.17k forks source link

[BUG] IOS pathnotfoundexception cannot delete file #3417

Closed hjspencer closed 8 months ago

hjspencer commented 1 year ago

The bug

I uploaded most of 30k images/videos via the CLI and the IOS app is slowly cycling though. I keep hitting an issue where I get a pathnotfoundexception error where it cannot delete a file.

2023-07-24 20:04:08.008999,LogLevel.SEVERE,"ImmichErrorLogger","PathNotFoundException: Cannot delete file, path = '/private/var/mobile/Containers/Data/Application/55A5903E-4A2D-4189-917E-3489335F978D/tmp/.image/1618857548.034431_o_20120913-134300_030.JPG' (OS Error: No such file or directory, errno = 2)","#0      _File.throwIfError (dart:io/file_impl.dart:675)
#1      _File._deleteSync (dart:io/file_impl.dart:329)
#2      FileSystemEntity.deleteSync (dart:io/file_system_entity.dart:424)
#3      BackupService.backupAsset (package:immich_mobile/modules/backup/services/backup.service.dart:318)
<asynchronous suspension>
#4      BackupNotifier.startBackupProcess (package:immich_mobile/modules/backup/providers/backup.provider.dart:460)
<asynchronous suspension>
#5      BackupNotifier._resumeBackup (package:immich_mobile/modules/backup/providers/backup.provider.dart:585)
<asynchronous suspension>
"
2023-07-24 19:57:18.622069,LogLevel.SEVERE,"ImmichErrorLogger","PathNotFoundException: Cannot delete file, path = '/private/var/mobile/Containers/Data/Application/55A5903E-4A2D-4189-917E-3489335F978D/tmp/.image/1618857414.051843_o_20130518-175200.JPG' (OS Error: No such file or directory, errno = 2)","#0      _File.throwIfError (dart:io/file_impl.dart:675)
#1      _File._deleteSync (dart:io/file_impl.dart:329)
#2      FileSystemEntity.deleteSync (dart:io/file_system_entity.dart:424)
#3      BackupService.backupAsset (package:immich_mobile/modules/backup/services/backup.service.dart:318)
<asynchronous suspension>
#4      BackupNotifier.startBackupProcess (package:immich_mobile/modules/backup/providers/backup.provider.dart:460)
<asynchronous suspension>
#5      BackupNotifier._resumeBackup (package:immich_mobile/modules/backup/providers/backup.provider.dart:585)

This stalls the process for a few mins (or sometimes fully and I need to force close the app) When the backup process starts again the remaining number of assets to backup has increase by sometime over 2000. It starts backing up assets but again stalls and I cycle round the same problem.

Do to the size of photos/videos on my phone I do have Photos optimised for iCloud Storage so it could be this that is too aggressive removing the image before Immich has completed backing up.

Happy to share logs

The OS that Immich Server is running on

QNAP QTS 5.0.1.2425

Version of Immich Server

v1.69.0

Version of Immich Mobile App

v1.68.0 build.108

Platform with the issue

Your docker-compose.yml content

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "immich" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /share/data/media/pictureshowie:/photobackup
      - /share/data/media/videoshowie:/videobackup
    env_file:
      - stack.env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "microservices" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - stack.env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - model-cache:/cache
    env_file:
      - stack.env
    restart: always

  immich-web:
    container_name: immich_web
    image: ghcr.io/immich-app/immich-web:${IMMICH_VERSION:-release}
    env_file:
      - stack.env
    restart: always

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.1@sha256:9bcff2b829f12074426ca044b56160ca9d777a0c488303469143dd9f8259d4dd
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
    logging:
      driver: none
    volumes:
      - tsdata:/data
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:70a7a5b641117670beae0d80658430853896b5ef269ccf00d1827427e3263fa3
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14-alpine@sha256:28407a9961e76f2d285dc6991e8e48893503cc3836a4755bbc2d40bcc272a441
    env_file:
      - stack.env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      PG_DATA: /var/lib/postgresql/data
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: ghcr.io/immich-app/immich-proxy:${IMMICH_VERSION:-release}
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    ports:
      - 2283:8080
    depends_on:
      - immich-server
      - immich-web
    restart: always

volumes:
  pgdata:
  model-cache:
  tsdata:

Your .env content

DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_PASSWORD=<Redacted>
DB_DATABASE_NAME=immich
REDIS_HOSTNAME=immich_redis
UPLOAD_LOCATION=/photos
TYPESENSE_API_KEY=<Redacted>
PUBLIC_LOGIN_PAGE_MESSAGE=
IMMICH_WEB_URL=http://immich-web:3000
IMMICH_SERVER_URL=http://immich-server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003

Reproduction steps

1. Open IOS app  and go to backup screen
2. Assets start backing up
3. After some time app get pathnotfoundexception error and remainder count stops
4. Leave or force close app
5. Open app > backup screen
6. remainder count has increased from where it was previously

Additional information

No response

alextran1502 commented 1 year ago

Hello, I assume you are using Shared Album feature from iOS?

hjspencer commented 1 year ago

I do have shared albums enabled but I don't have any shared. I did have a mate who shared an album woth me quite some time agao but I can't see it now so I assume he's turned that off. I've disabled the feature

hjspencer commented 1 year ago

With the shared album feature disabled I've just had another pathnotfoundexception error. I left the app for over 10 mins but it didn't kick back in backing up photos so I had to force close it It was down to around 700 left. When re-opening it was over 2000

alextran1502 commented 10 months ago

Hello is this issue still relevance?

traktuner commented 10 months ago

Hello! I have the same issue. Same error as OP, shared albums was enabled, went away when "shared albums" are disabled in iOS (even if no shared album is present on the device, feature was not used).

When enabled, the selection screen where you chose which album to back up won't load (loading animation)

jetblack-nz commented 10 months ago

Same issue here on the latest iOS, no shared albums. The backup stalls every few minutes with the pathnotfoundexception in the logs. I have also commented on the other github issue for this.

alextran1502 commented 10 months ago

@jetblack-nz Just for some more data points, which phone model are you one, and which features of Photos are you using, such as iCloud...etc?

jetblack-nz commented 10 months ago

@alextran1502 this is related to the other issue I commented on today: https://github.com/immich-app/immich/issues/4339#issuecomment-1811493506

bw1faeh0 commented 8 months ago

Same (?) Problem here.

MESSAGE:

Catch all error: PathNotFoundException: Cannot delete file, path = '/private/var/mobile/Containers/Data/Application/FEC06F14-E47E-4A21-ABA1-EE91DAAD47FA/tmp/.image/93170CDF-5E02-489A-8E43-1499CF3863CD_L0_001_1692334770.196182_o_FullSizeRender.jpg' (OS Error: No such file or directory, errno = 2) - PathNotFoundException: Cannot delete file, path = '/private/var/mobile/Containers/Data/Application/FEC06F14-E47E-4A21-ABA1-EE91DAAD47FA/tmp/.image/93170CDF-5E02-489A-8E43-1499CF3863CD_L0_001_1692334770.196182_o_FullSizeRender.jpg' (OS Error: No such file or directory, errno = 2)

FROM:

ImmichErrorLogger

STACK TRACES:

#0      _File.throwIfError (dart:io/file_impl.dart:675)
#1      _File._deleteSync (dart:io/file_impl.dart:329)
#2      FileSystemEntity.deleteSync (dart:io/file_system_entity.dart:424)
#3      BackupService.backupAsset (package:immich_mobile/modules/backup/services/backup.service.dart:398)
<asynchronous suspension>
#4      BackupNotifier.startBackupProcess (package:immich_mobile/modules/backup/providers/backup.provider.dart:461)
<asynchronous suspension>
#5      BackupNotifier._resumeBackup (package:immich_mobile/modules/backup/providers/backup.provider.dart:592)
<asynchronous suspension>

After 24 h only 500 of 12500 pics are backed up.

alextran1502 commented 8 months ago

This issue should be fixed in 1.91.4

iansewell commented 8 months ago

still happening for me in 1.91.4 when run as background task, it seems to be ok for foreground? different code path? (iphone 12 pro, icloud sync, latet immich server)