Re: Add pre-scan task?
Michael Herger <slim-b/[email protected]> Fri, 25 Mar 2022 16:47:44 +0100
| Newsgroups | gmane.music.equipment.slimdevices.devel |
|---|---|
| Message-ID | <[email protected]> |
> About file paths: what's the safest way (considering escaping, special > chars, different OS peculiarities...) in Perl to get the *relative* path > of -local- files from the database file urls. So from > "file:///some/media/dir/artist/album/file.ext" to > "artist/album/file.ext". > Would you use -File::Spec- or -Path::Class- or something else? Ideally, > my backup would store relative paths. Then if users change the media dir > it would still be valid. TBH: I don't know off the top of my head. I would have suggested looking into Path::Class, which has some methods to work with children, relative paths etc. > But if users have > 1 media dir the plugin would have to test the > relative file paths from the old backup with each currently valid media > dir. If you're dealing with 1000s of urls, what's the fastest way to > check if a file url is valid, i.e. that the file at that url exists? -f path/to/file I wouldn't know of any faster way, because you'll have to read the filesystem info at some point anyway.