Open brucejackson opened 3 years ago
Oh, interesting! /
vs. \
. That's indeed a bug. Let me check.
Now that's tricky. We're just joining the base dir with the relative path here:
https://github.com/gramps-project/gramps-webapi/blob/master/gramps_webapi/api/file.py#L78
The problem is, Linux allows backslashes in file names. So it's not easy for us to know whether the relative path is supposed to be a Unix filename with backslashes or a Windows file path. AFAIK Gramps does not keep track of what kind of path it stores.
The only fix that comes to my mind is to try the file, if it doesn't exist, try treating it as a path.
Another option could be to create a new configuration variable:
MEDIA_PATH_WINDOWS = True; Backslash are directories and need to be converted
MEDIA_PATH_WINDOWS = False; Carry on with existing logic.
Or, could you check the value of the "Base Path for Relative Media"? If it starts with a drive letter and a colon, the database was probably created on a windows platform. If it starts with a '/' it should be a Linux or Mac platform.
Yes. Functions like os.path.normpath
don't help here.
Checking for the drive letter is a good idea, but it doesn't really help in full generality as F:\
happens to be a perfectly valid filename on POSIX systems!
So I think the most robust & simple solution is to check whether the POSIX interpretation works, and check the Windows one second. It would also work with Datbases that have a mix of both styles. While this sounds crazy, it might actually start happening when we allow file uploads via the web API to a database running on a Linux server that was previously used with Windows.
Environment:
Issue: When browsing my family tree via with Gramps.js and gramps-webapi, no media images are visible in the browser.
Details. I reviewed the docker log files and noted this error message:
FileNotFoundError: [Errno 2] No such file or directory: '/app/media/People\\H\\Henders__Dorothy_Estelle\\Henders__Dorothy_Estelle-Gravestone-2005.jpg'
I then opened the CLI for the docker container to confirm the images were accessible within the docker container. They appear to be. (asterisks added for emphasis)
My docker-compose.yml is: (asterisks added for emphasis)
In my config.cfg for the Gramps-webapi, I have the following set:
MEDIA_BASE_DIR="/app/media"
In Gramps I use relative paths:
Thanks, Bruce.