Quote:
Originally Posted by itimpi
You are correct!
It is surprisingly hard to reliably detect the case where the database and the file-system do not match as checking for file-existence works if Calibre2opds is run on a case-independent system. If someone could suggest a way (that can be used from Java) to program such a check in a robust way tha runs on all supported platforms it would probably be incorporated. I am sure if it wax easy Calibre itself would also make sure they matched.
|
The problem you face is indeed difficult to begin with, made even more difficult because the catalog can be generated on a system with different rules.
My suggestion is that you assume that calibre2opds is being run on the system where calibre is run. In this case you can use filesystem paths when you generate a URL. For example, you could use the database path to open an item (read-only, perhaps open isn't needed), ask the OS for the real path, then use that. Such a scheme would generate paths that work on either case-sensitive or -insensitive systems, because you would be using the exact string found in the file system.
I haven't yet decided how to do this in my PHP server. My problem is that the server is not running on the system where the paths were created, so I don't get the chance to do case conversion using the open/path trick. Segment by segment searches (open a directory, get the list of files, lcase them, and compare by hand) might work, but such searches would be expensive.