Skip to content

Commit

Permalink
Add _meta.json URI during imagery conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Aug 23, 2017
1 parent 2565901 commit bf1e269
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
env:
global:
# Set OAM_DEBUG=true in Travis UI to see debug output
- OAM_DEBUG=true
- NODE_ENV=test
- GH_REF=github.com/hotosm/oam-catalog.git
- PRODUCTION_BRANCH=master
Expand Down
5 changes: 3 additions & 2 deletions services/s3_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ module.exports = class S3Sync {

// Don't try to manipulate metadata files that aren't in OIN's public bucket.
isOINMeta () {
// TODO: Also match the S3 domain for more rigorous matching.
return this.remoteMetaUri.includes(`/${config.oinBucket}/`);
let isInDomain = this.remoteMetaUri.includes(`${config.oinBucket}.${config.s3PublicDomain}`);
let isInPath = this.remoteMetaUri.includes(`/${config.oinBucket}/`);
return isInDomain || isInPath;
}

updateRemoteMeta (newDetails, callback) {
Expand Down
1 change: 1 addition & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
# locally, the codebase is mounted from the host, including
# the `.env` file, so the `dotenv` npm module takes responsibility
# for loading these values.
- OAM_DEBUG
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- FACEBOOK_APP_ID
Expand Down
11 changes: 11 additions & 0 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ module.exports = {
// This comes from the periodic cron to check the bucket for
// new imagery. Once a new image's *meta.json is found it is
// parsed and added to the DB.
// TODO:
// This is no longer necessary as the _meta.json URI is actually
// added at the point of conversion. Before the conversion step
// added the metadata URI we had to wait for the background cron
// worker process to index new metadata files from S3. This was
// good for testing, because it meant that this function was
// testing that background worker process (`/catalog-worker.js`
// at time of writing). I'm not aware that this indexing step
// adds anything at all new that we can detect. Therefore the
// best solution would just be to write dedicated tests for the
// indexing process.
waitForIndexing: function (title, processedCb) {
var getOptions = {
url: config.apiEndpoint + '/meta?title=' + title,
Expand Down
5 changes: 4 additions & 1 deletion worker/process-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,17 @@ function _processImage (scene, sourceUrl, targetPrefix, callback) {

log(['debug'], 'Converted image to OAM standard format. Input: ', sourceUrl, 'Output: ', output);

var metaUri = `http://${s3bucket}.s3.amazonaws.com/${targetPrefix}_meta.json`;

return request.get({
json: true,
uri: `http://${s3bucket}.s3.amazonaws.com/${targetPrefix}_meta.json`
uri: metaUri
}, function (err, rsp, metadata) {
if (err) {
return _callback(err);
}

metadata.meta_uri = metaUri;
return _callback(null, {
metadata: metadata
});
Expand Down

0 comments on commit bf1e269

Please sign in to comment.