share my solution to get Synology photos auto index working with syncthing

thanks for this great project and I’m here to share my solution to get Synology photos auto index working with syncthing.

So I have 2 Synology nas, need to sync files between them. Was using Synology drive share sync, buggy and painfully slow. Switched to syncthing in dockers and it’s so much better user experience/performance.

But photo files synced via syncthing is not showing up in Synology photos. I have to manually trigger reindex for them to show up.

Tried some solution like letorbi/synoindexwatcher and didn’t work, but I found some useful infomation here: DSM7 (Synology Photo) compatibility · Issue #51 · letorbi/synoindexwatcher · GitHub

Reason for the issue being:

The process which listens for changes, and activates the auto indexing service does not directly monitor the disc for file changes. It instead communicates with other services to determine when a change is made, and then activates the indexing process. Unfortunately, changes to the disk via docker is not one of the things this process currently monitors.

Synology photos monitor file updated via smb and other regular protocols but not via direct mounted docker.

I got it working by mount the Synology path as a local smb volume instead of direct mount, so that the triffic is treated as smb operations.

sample docker compose:

version: '3'

services:
  syncthing:
    image: syncthing/syncthing:latest
    container_name: syncthing-syncthing-compose
    volumes:
      - photo:/photo
      - homes:/homes
    environment:
      - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      - PUID=0
      - PGID=0
      - HOME=/var/syncthing
      - STGUIADDRESS=0.0.0.0:8384
      - STHOMEDIR=/var/syncthing/config
    network_mode: host
    ports:
      - "21027/udp"
      - "22000/tcp"
      - "22000/udp"
      - "8384/tcp"

volumes:
  homes:
    driver_opts:
      type: cifs
      o: iocharset=utf8,username=<smb_username>,password=<smb_password>,vers=3.0
      device: //127.0.0.1/homes
  photo:
    driver_opts:
      type: cifs
      o: iocharset=utf8,username=<smb_username>,password=<smb_password>,vers=3.0
      device: //127.0.0.1/photo

This can be a solution for all issues caused by Synology won't auto index my file created via docker, I’ve seen people talk about it in the radarr/sonarr community.

It works with 2 caveats:

  1. seems only working with docker PID=0. otherwise I’m having permission denied. But the updated file come with owner of the smb user instead of root.
  2. as was mentioned 3 years ago by @calmh : SMB share of Syncthing folder? - #2 by calmh

When Syncthing is accessing a folder over SMB it needs to rely on periodic scans instead of change notifications. Changes still get picked up, but with slightly higher latency.

It’s not a real time syncing experience , need to wait for the interval scan to pickup new changes, but toally acceptable to me. Is it possible to get real time notifications over SMB now? Didn’t find much docs about this topic.

Hope this helps you if you are also having this problem, and let me know if the 2 caveats can somehow be solved. Cheers!

1 Like

If PUID=1234 and PGID=1234, add the uid and gid mount options like this:

o: iocharset=utf8,username=<smb_username>,password=<smb_password>,uid=1234,gid=1234,vers=3.0

Although it’s usually not necessary, forceuid and forcegid can also be helpful:

o: iocharset=utf8,username=<smb_username>,password=<smb_password>,forceuid,uid=1234,forcegid,gid=1234,vers=3.0

Microsoft added change notification to the SMB2 protocol.

Samba’s kernel change notify parameter (enabled by default) supports using the Linux kernel’s inotify subsystem, and in turn notifying compatible SMB/CIFS clients via the SMB2 protocol.

But as far as I’m aware of, adding support into the Linux kernel’s CIFS client module is a work-in-progress.