RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
2k stars 94 forks source link

Autodetect SMB volumes and force use of RAM DB #1419

Open RhetTbull opened 6 months ago

RhetTbull commented 6 months ago

Using osxphotos over a Synology NAS (and likely other SMB volumes) can be horribly slow due to SQLite performance over these very slow network volumes. Detect if volume is SMB and if so, use --ramdb automatically. Add a --no-ramdb that prevents this if required.

See #1415 and #1418

See this discussion for a way of detecting if volume is SMB.

RhetTbull commented 6 months ago

This appears to work on macOS:

def is_smbfs_path(path):
    path_device = os.stat(path).st_dev
    mounts = os.popen("mount").readlines()
    for mount in mounts:
        if "(smbfs" in mount:
            mnt_device = os.stat(mount.split(" ")[2]).st_dev
            if mnt_device == path_device:
                return True
    return False