Skip to content

Commit

Permalink
Don't throw if a doc hasn't been versioned yet (#455)
Browse files Browse the repository at this point in the history
Instead of throwing, return `null` because that means we have a
new doc in our versioning sequence

(Also, cleaned up a bit of code as I researched this)

Partial Fix To #450
  • Loading branch information
JoelMarcey authored Feb 17, 2018
1 parent 5dd8b73 commit 1388e13
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/server/versionFallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ files.forEach(file => {
// what the requested version is
function docVersion(id, req_version) {
if (!available[id]) {
throw new Error(
`Document with id '${id}' was requested but no document with that id could be located.`
);
return null;
}
// iterate through versions until a version less than or equal to the requested
// is found, then check if that version has an available file to use
Expand Down
3 changes: 1 addition & 2 deletions lib/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ files.forEach(file => {
metadata.original_id = metadata.id;
metadata.id = 'version-' + version + '-' + metadata.id;

const targetFile =
CWD + '/versioned_docs/version-' + version + '/' + path.basename(file);
const targetFile = versionFolder + '/' + path.basename(file);

fs.writeFileSync(targetFile, makeHeader(metadata) + rawContent, 'utf8');
});
Expand Down

0 comments on commit 1388e13

Please sign in to comment.