I suggest a different approach:
why not initially send a full list of all primitives available to the client before he starts to download individual files?
then he can know that everything else is a part. no more regex guessing.
the same goes for "unofficial files vs official file":
can't the client initially get a simple list of all unofficial (or: official) files?
he could even locally cache it.
then also no more guesswork with regexes would be needed.
Of course, if these lists get very large, the benefit would be spoiled, but currently I think:
- the download of such lists could be faster than N failed URL accesses
- the downloaded list could be cached on client side maybe
- it could be sent in compressed form
- it could be pre-calculated on the server
While I am writing this, I come to another idea:
the server knows everything about every file.
it knows what is a primitive and what is a part etc.,
and which one is official and which one is unofficial.
Thus, when a client requests to download some file, say 777.dat,
the server can help the client and compile a list of "meta" info for the client, telling him
which file is official and which one not, and the folder in which it is to be found.
The client would access something like
www.ldraw.org/get_list_of_required_files_for?777.dat
, and the server would reply with a JSON which could look like
This reply will make it easy for the client to construct the URL for downloading the required files.
why not initially send a full list of all primitives available to the client before he starts to download individual files?
then he can know that everything else is a part. no more regex guessing.
the same goes for "unofficial files vs official file":
can't the client initially get a simple list of all unofficial (or: official) files?
he could even locally cache it.
then also no more guesswork with regexes would be needed.
Of course, if these lists get very large, the benefit would be spoiled, but currently I think:
- the download of such lists could be faster than N failed URL accesses
- the downloaded list could be cached on client side maybe
- it could be sent in compressed form
- it could be pre-calculated on the server
While I am writing this, I come to another idea:
the server knows everything about every file.
it knows what is a primitive and what is a part etc.,
and which one is official and which one is unofficial.
Thus, when a client requests to download some file, say 777.dat,
the server can help the client and compile a list of "meta" info for the client, telling him
which file is official and which one not, and the folder in which it is to be found.
The client would access something like
www.ldraw.org/get_list_of_required_files_for?777.dat
, and the server would reply with a JSON which could look like
Code:
{
"official" :
[
{ "s" : [ "777s01.dat", "777s02.dat" ] },
{ "p" : [ "4-4disc.dat", "4-4cyli.dat" ] },
{ "p/48" : [ "2-4ndis.dat", "stud.dat" ] },
{ "p/8" : [ "2-4ndis.dat", "stud.dat" ] }
],
"unofficial" :
[
{ "s" : [ "123s01.dat", "456s02.dat" ] },
{ "p" : [ "3-4disc.dat", "3-4cyli.dat" ] }
]
}