Skip to content

Scan doesn't work if library section is file root and content is added to root #14

@quincyzhuang

Description

@quincyzhuang

Description

I've set up my media directory on my NAS like described in this article, where each subdirectory under Media is a library section.

/Media
   /Movies
      movie content
   /Music
      music content
   /TV Shows
      television content

e.g. I have a library section called Movies that has no folders within, just a bunch of movie files.

I've found that with this setup, scans seem to think that the files I add/modify/remove are paths, and Plex treats them as paths and fails to pick it up.

In this example, I add a file Hercules (1997).m4v to my Movies folder on my NAS (I'll attach my .env and docker-compose later down this post)

docker logs
...
INFO:	Adding to queue for section Movies (created): Hercules (1997).m4v
INFO:	Requesting Plex to scan the remote path /Movies/Hercules (1997).m4v
...
Plex console
...
Dec 04, 2025 22:58:33.066 [136485292485432] DEBUG - Performing a scan with 'Plex Movie' (language: en-US virtual: 0).
Dec 04, 2025 22:58:33.066 [136485292485432] DEBUG -   * Scanning /Movies/Hercules (1997).m4v
Dec 04, 2025 22:58:33.153 [136485292485432] ERROR - Failed to create iterator to "/Movies/Hercules (1997).m4v": Not a directory
Dec 04, 2025 22:58:33.191 [136485292485432] DEBUG - Scanner: Processing directory /Movies/Hercules (1997).m4v (parent: yes)
Dec 04, 2025 22:58:33.191 [136485292485432] VERBOSE -     * Noting that 'Hercules (1997).m4v' was updated at 2025-12-04 22:49:42
Dec 04, 2025 22:58:33.191 [136485292485432] VERBOSE -     * Taking directory 'Hercules (1997).m4v' (121) out of the map (0 left)

I think the issue is introduced here:
https://github.com/LightDestory/PlexNFSWatchdog/blob/master/src/plex_nfs_watchdog/modules/plex/plex_agent.py#L234

 for location in self._internal_sections[section_id]["locations"]:
            scan_path: Path = Path(location / item).absolute()
            logging.info(f"Requesting Plex to scan the remote path {str(scan_path)}")
            if shared.user_input.dry_run:
                logging.info("Skipping Plex scan due to dry-run")
            else:
                plex_section.update(str(scan_path))

Here, location would be set to /Movies and item would be set to Hercules (1997).m4v. However, item is supposed to be a folder, not a file. The proper thing to do would be to ask Plex to scan the /Movies path.

I can fix this by creating a folder within Movies and adding stuff there, which works like a charm because the scan is for /Movies/<subfolder>, but I think permitting scans of the entire library section (in my case where i don't have sub folders) should be a supported usecase, even if the intent seems to be to only allow partial scans on subfolders.

Reproduction

docker-compose

services:
  plexnfswatchdog:
    build: .
    image: plexnfswatchdog
    container_name: plexnfswatchdog
    restart: unless-stopped
    env_file: ./.env
    environment:
      - PLEX_SERVER=${PLEX_SERVER}
      - PLEX_TOKEN=${PLEX_TOKEN}
      - WATCH_PATHS=${WATCH_PATHS}
      - SCAN_INTERVAL=${SCAN_INTERVAL}
      - LISTENERS=${LISTENERS}
      - ALLOW_FOLDER=${ALLOW_FOLDER}
      - ALWAYS_OVERWRITE_CONFIG=${ALWAYS_OVERWRITE_CONFIG}
    volumes:
      - /volume1/Media/Movies:/volume1/Media/Movies:ro

.env

# Plex Configuration
PLEX_SERVER=http://192.168.86.168:32400
PLEX_TOKEN=<my token>

# Watchdog Configuration
WATCH_PATHS=/volume1/Media/Movies
SCAN_INTERVAL=30
LISTENERS=move modify create delete

To replicate:

  1. Plex server: NFS Mount /volume1/Media/Movies on your storage server to /mnt/nas/Movies
  2. Plex server: Create a library section in Plex called Movies that points to the mounted folder /Movies
  3. Start nfs watchdog with provided docker-compose on the storage server
  4. Add a file to volume1/Media/Movies/ on the storage server
  5. Plex will acknowlege the scan request, but will fail to add the file to the library

Environment

Storage server running nfs watchdog:

Linux nas 4.4.302+ #72806 SMP Mon Jul 21 23:12:58 CST 2025 x86_64 GNU/Linux synology_r1000_923+

Plex server

Linux myServer 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov  6 17:42:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions