Problem/Motivation
While trying to alter the paths/filenames of the exports I noticed the many calls to \Drupal\tome_static\StaticGenerator::getDestination which aren't used or seem to be needed.
1. in requestPath() right before
if ($response->isRedirection() || $response->isOk()) {
The $destination is only used inside the if. No need to have it outside.
2. in exportPaths before the copyPath() call.
I would suggest checking if the sanitized path exists before calling the getDestination-method, since it's only of use if it exists and we want to copy.
Yeah, I know, copyPath also does a file_exists(), but that doesn't bother me as much as the getDestination-calls.
Why care about those calls, they're nothing right?
1. When debuging the path-altering-stuff, it's pretty annoying to go through bunch of paths which aren't in the export anyway (for reasons, mostly 404. Probably language issues on my end. Who knows).
2. And also I'm bit worried about performance. Might not be a big deal for a small number of pages, but I'll have a multi-site thing where some sites have hundreds of pages (and each page I have to export multiple times, for reasons™ we're better not get into).
Proposed resolution
1. Just move the getDestination call inside the if
2. Do a file_exists on the sanitized path first, if that passes call getDestination to do the copyPath.
Remaining tasks
I'll provide a patch pretty soon.
User interface changes
none.
API changes
not that I can see.
Data model changes
nope.
As far as I can see this shouldn't change anything on the resulting export. As I said, the $destinations are only used inside the if-cases.