[BUG] Android App not recognizing new images in synced folder that is moved automatically using cronjob bash script #809

Closed
opened 2026-02-04 22:47:55 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @thisispatman on GitHub (Apr 12, 2023).

The bug

I already posted this on Reddit (https://www.reddit.com/r/immich/comments/12fw0ha/android_app_ignores_some_photos_in_syncfolder/) and was told to open an issue here; so here we go:

I use the Immich Android App on my phone to upload pictures to my server. For photos/pictures from the Signal Messenger app, I have a cronjob to add EXIF-data to the pictures, bevore moving them in the folder the App uses.
The relevant lines (those actually performing changes on the picture) from the cron-triggered script are:

#!/system/xbin/bash
cd /sdcard/Pictures
for file in $(ls /sdcard/Pictures/signal-*)
do
        [...] # acquiring date and time from filename
        /data/data/com.termux/files/usr/bin/exiftool $file -overwrite_original_in_place -CreateDate="$myear:$mymonth:$myday $myhour:$myminute:$mysecond"
        /data/data/com.termux/files/usr/bin/exiftool $file -overwrite_original_in_place -DateTimeOriginal="$myear:$mymonth:$myday $myhour:$myminute:$mysecond"
        cp $file /sdcard/Pictures/Upload/
        rm $file
done

The Upload folder is configured in the Immich App:

This screenshot is also the starting point for the description of the bug:

  • Immich recognizes one picture in the folder
  • there is actually one picture in the folder, so everything is correct

I now save pictures from Signal, which are saved in /data/Pictures and the Cronjob does it's thing, adding EXIF-data and moving those files to /data/Pictures/Upload:

  • I now have 6 pictures in the folder
  • Immich doesn't recognize there were pictures added, still shows one image:
  • the log shows state is already up-to-date

Now I restart my phone and as soon as it comes up again, the Immich app sees the new pictures:

The app now uploads the pictures as intended.

Why is it, Immich doesn't recognize new files in the Upload-folder?
When I copy a file by hand, without the script, it works and Immich immediately recognizes an added file.

The OS that Immich Server is running on

Rocky Linux 9.1 (Blue Onyx)

Version of Immich Server

1.53.0

Version of Immich Mobile App

1.53.0 build.76

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

Not relevant, since it's an issue in the Android App - if needed, I can give that later.

Your .env content

Not relevant, since it's an issue in the Android App - if needed, I can give that later.

Reproduction steps

See description above.

Additional information

No response

Originally created by @thisispatman on GitHub (Apr 12, 2023). ### The bug I already posted this on Reddit (https://www.reddit.com/r/immich/comments/12fw0ha/android_app_ignores_some_photos_in_syncfolder/) and was told to open an issue here; so here we go: I use the Immich Android App on my phone to upload pictures to my server. For photos/pictures from the Signal Messenger app, I have a cronjob to add EXIF-data to the pictures, bevore moving them in the folder the App uses. The relevant lines (those actually performing changes on the picture) from the cron-triggered script are: ``` #!/system/xbin/bash cd /sdcard/Pictures for file in $(ls /sdcard/Pictures/signal-*) do [...] # acquiring date and time from filename /data/data/com.termux/files/usr/bin/exiftool $file -overwrite_original_in_place -CreateDate="$myear:$mymonth:$myday $myhour:$myminute:$mysecond" /data/data/com.termux/files/usr/bin/exiftool $file -overwrite_original_in_place -DateTimeOriginal="$myear:$mymonth:$myday $myhour:$myminute:$mysecond" cp $file /sdcard/Pictures/Upload/ rm $file done ``` The Upload folder is configured in the Immich App: <img src="https://user-images.githubusercontent.com/17691492/231563480-997513ec-47d9-4adc-bebb-b3302392f1cc.png" width="300"> This screenshot is also the starting point for the description of the bug: * Immich recognizes one picture in the folder * there is actually one picture in the folder, so everything is correct <img src="https://user-images.githubusercontent.com/17691492/231563689-c8f10640-bbf2-4777-824c-03cc3af74498.png" width="300"> I now save pictures from Signal, which are saved in `/data/Pictures` and the Cronjob does it's thing, adding EXIF-data and moving those files to `/data/Pictures/Upload`: <img src="https://user-images.githubusercontent.com/17691492/231564919-2b76c9dc-ddf5-44d1-8133-6205b4417017.png" width="300"> * I now have 6 pictures in the folder * Immich doesn't recognize there were pictures added, still shows one image: <img src="https://user-images.githubusercontent.com/17691492/231564202-3fd4bacc-5efc-49c8-933a-9e518e4541cd.png" width="300"> * the log shows state is already up-to-date <img src="https://user-images.githubusercontent.com/17691492/231564304-ad62f058-d715-4da2-b6df-106cc9eb9916.png" width="300"> Now I restart my phone and as soon as it comes up again, the Immich app sees the new pictures: <img src="https://user-images.githubusercontent.com/17691492/231565144-e1c4c9a3-5f20-4885-ae0a-1e5205998801.png" width="300"> The app now uploads the pictures as intended. <img src="https://user-images.githubusercontent.com/17691492/231565215-f8b92bbc-0739-4579-8b03-bff4febff6ea.png" width="300"> Why is it, Immich doesn't recognize new files in the Upload-folder? When I copy a file by hand, without the script, it works and Immich immediately recognizes an added file. ### The OS that Immich Server is running on Rocky Linux 9.1 (Blue Onyx) ### Version of Immich Server 1.53.0 ### Version of Immich Mobile App 1.53.0 build.76 ### Platform with the issue - [ ] Server - [ ] Web - [X] Mobile ### Your docker-compose.yml content ```YAML Not relevant, since it's an issue in the Android App - if needed, I can give that later. ``` ### Your .env content ```Shell Not relevant, since it's an issue in the Android App - if needed, I can give that later. ``` ### Reproduction steps ```bash See description above. ``` ### Additional information _No response_
Author
Owner

@alextran1502 commented on GitHub (Apr 12, 2023):

Maybe the cronjob copy-file doesn't entirely move and register the necessary information for the internal file system that the library Immich uses to read/scan the phone file system. And upon restarting the phone, it rescans the file and writes the correct information to the internal file system for the app to check. That is my gut guess

@alextran1502 commented on GitHub (Apr 12, 2023): Maybe the cronjob copy-file doesn't entirely move and register the necessary information for the internal file system that the library Immich uses to read/scan the phone file system. And upon restarting the phone, it rescans the file and writes the correct information to the internal file system for the app to check. That is my gut guess
Author
Owner

@thisispatman commented on GitHub (Apr 12, 2023):

Maybe the cronjob copy-file doesn't entirely move and register the necessary information for the internal file system that the library Immich uses to read/scan the phone file system. And upon restarting the phone, it rescans the file and writes the correct information to the internal file system for the app to check. That is my gut guess

That's kind of obvious I feel ashamed to have thought this was an Immich issue 😅
For testing purposes: I have duplicated an image file and a) moved it to the Upload folder using Termux (Terminal) and b) the Gallery-App.
The picture from a) does not appear in Immich directly, the image from b) does. After a restart, both are present!

So that's it. Thank you very much for the quick response/help!
I now need to find a way to scan the folder from my script then... termux-media-scan, which I found, does not work unfortunately.

edit: Using an app like SD Scanner (https://f-droid.org/packages/com.gmail.jerickson314.sdscanner/) makes Immich recognize the pictures without a restart of the phone!

See also: https://www.reddit.com/r/termux/comments/11isezc/comment/jazrwn9/?utm_source=share&utm_medium=web2x&context=3

@thisispatman commented on GitHub (Apr 12, 2023): > Maybe the cronjob copy-file doesn't entirely move and register the necessary information for the internal file system that the library Immich uses to read/scan the phone file system. And upon restarting the phone, it rescans the file and writes the correct information to the internal file system for the app to check. That is my gut guess That's kind of obvious I feel ashamed to have thought this was an Immich issue :sweat_smile: For testing purposes: I have duplicated an image file and a) moved it to the Upload folder using Termux (Terminal) and b) the Gallery-App. The picture from a) does not appear in Immich directly, the image from b) does. After a restart, both are present! So that's it. Thank you very much for the quick response/help! I now need to find a way to scan the folder from my script then... `termux-media-scan`, which I found, does not work unfortunately. **edit:** Using an app like SD Scanner (https://f-droid.org/packages/com.gmail.jerickson314.sdscanner/) makes Immich recognize the pictures without a restart of the phone! See also: https://www.reddit.com/r/termux/comments/11isezc/comment/jazrwn9/?utm_source=share&utm_medium=web2x&context=3
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#809