update cache mechanism to handle forced profile
This commit is contained in:
parent
999211ed9c
commit
59f8330db4
@ -20,11 +20,11 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
hashOfFile: (path, cb) => {
|
||||
hashOfFile: (path, additional_content, cb) => {
|
||||
fs.readFile(path, (err, result) => {
|
||||
if (err) return cb(err);
|
||||
let checksum = crypto.createHash('md5');
|
||||
checksum.update(result);
|
||||
checksum.update(result + (additional_content || "") );
|
||||
cb(null, checksum.digest('hex'));
|
||||
});
|
||||
}
|
||||
|
@ -28,13 +28,16 @@ module.exports = function() {
|
||||
let uri = feature.getUri();
|
||||
|
||||
// setup cache for feature data
|
||||
hash.hashOfFile(uri, (err, hash) => {
|
||||
// if OSRM_PROFILE is set to force a specific profile, then
|
||||
// include the profile name in the hash of the profile file
|
||||
hash.hashOfFile(uri, this.OSRM_PROFILE, (err, hash) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
// shorten uri to be realtive to 'features/'
|
||||
let featurePath = path.relative(path.resolve('./features'), uri);
|
||||
// bicycle/bollards/{HASH}/
|
||||
let featureID = path.join(featurePath, hash);
|
||||
let featureID = path.join(featurePath, hash);
|
||||
|
||||
let featureCacheDirectory = this.getFeatureCacheDirectory(featureID);
|
||||
let featureProcessedCacheDirectory = this.getFeatureProcessedCacheDirectory(featureCacheDirectory, this.osrmHash);
|
||||
this.featureIDs[uri] = featureID;
|
||||
|
@ -45,7 +45,7 @@ module.exports = function () {
|
||||
this.OSRM_PORT = process.env.OSRM_PORT && parseInt(process.env.OSRM_PORT) || 5000;
|
||||
this.HOST = 'http://127.0.0.1:' + this.OSRM_PORT;
|
||||
|
||||
this.OSRM_PROFILE = process.env.PROFILE
|
||||
this.OSRM_PROFILE = process.env.OSRM_PROFILE
|
||||
|
||||
if (this.PLATFORM_WINDOWS) {
|
||||
this.TERMSIGNAL = 9;
|
||||
|
Loading…
Reference in New Issue
Block a user