Skip to content
This repository was archived by the owner on Apr 21, 2021. It is now read-only.

Conversation

@LukasLohoff
Copy link
Contributor

The loader now uses the ID specified in erc.yml (#44 ) for compendia:

  • Reads ID from erc.yml
  • Checks for validity and if a compendium with the ID already exists
  • Added tests for invalid ID & duplicate ID
  • Reworked tests to reset database and local compendium storage before each test


} catch (error) {
debug('[%s] Could not read compendium detection file %s: %s', passon.id, passon.detectionFile, error);
error.msg = 'Could not read compendium detection file';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not reading the compendium detection file, but the "compendium configuration file", see http://o2r.info/erc-spec/spec/#erc-configuration-file

Before it was only used for detection. Please rephrase.

lib/steps.js Outdated
reject(error);
} else {
// Validate compendium id
let idRegex = new RegExp(config.bagtainer.id_regex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think new RegExp is not neccessary, you can directly do config.bagtainer.id_regex.test(compendiumID).

lib/steps.js Outdated
const Stream = require('stream');
const meta = require('../lib/meta');
const yaml = require('js-yaml');
const randomstring = require('randomstring');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randomstring is not used in this file AFAICS

lib/steps.js Outdated
reject(err);
}
if (compendium === null) {
debug('[%s] Assigned new ID %s to compendium', passon.id, compendiumID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify here: you are assigning the id loaded from the configuration file, not a "new" one.

debug(error, stderr, stdout);
let errors = error.message.split(':');
let message = errorMessageHelper(errors[errors.length - 1]);
error.msg = 'moving compendium files to new location failed: ' + message;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you thought about what do do with the files on an error here? Should they be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to delete the directory as it's just a directory with a randomly generated name (from the ID)

let cmd = 'mv ' + passon.compendium_path + ' ' + updatedPath;
exec(cmd, (error, stdout, stderr) => {
if (error || stderr) {
debug(error, stderr, stdout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a short message to this debug statement. Printing all outputs is good, a short text helps identifying where the error happens.

package.json Outdated
{
"name": "o2r-loader",
"version": "0.10.0",
"version": "0.10.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more than just a bugfix, please set version to 0.11.0

@nuest
Copy link
Member

nuest commented Mar 27, 2018

The tests on Travis fail (https://travis-ci.org/o2r-project/o2r-loader/builds/358827922):

/loader/node_modules/bindings/bindings.js:88
        throw e
        ^
Error: Error relocating /loader/node_modules/detect-character-encoding/build/Release/icuWrapper.node: utrace_cleanup_59: symbol not found
    at Object.Module._extensions..node (module.js:681:18)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at bindings (/loader/node_modules/bindings/bindings.js:81:44)
    at Object.<anonymous> (/loader/node_modules/detect-character-encoding/index.js:3:37)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/loader/lib/steps.js:34:33)

@LukasLohoff You did not change the Dockerfile, so this surprises me... it seems to be the same issue we had with sonicdoe/detect-character-encoding#8

  • try out locally with with the current base image node:8-alpine
  • try out locally with base image node:9-alpine (should not make a different, both use alpine:3.6!)
  • try out locall with node:8-slim

@nuest
Copy link
Member

nuest commented Mar 27, 2018

node:8-slim seems to have worked, but now we have troubles with the test setup, the test code cannot delete the files created by the microservice containers because the travis user is not root...


RUN apk add --no-cache \
RUN apt-get update && apt-get install -y \
python \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this install Python 2 or 3? IIRC this is used for npm package bagit, just in case one of the tests with bags fails now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It installs python 2. bagit should work, I verified that in a separate node:8-slim container

@nuest nuest merged commit 2195b01 into o2r-project:master Mar 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants