Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cloudhead/resourcer
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Apr 9, 2011
2 parents 53399b1 + fc653b3 commit 0fd2e47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/resourcer/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ resourcer.define = function (name, definition) {

F.resource = name;
F.key = '_id';
F.views = {};
F._children = [];
F._parents = [];

Expand Down
14 changes: 10 additions & 4 deletions lib/resourcer/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ this.Resource = function () {
};
this.Resource.filter = require('resourcer/resource/view').filter;

this.Resource.views = {};

//
// Hooks
//
Expand Down Expand Up @@ -355,8 +353,16 @@ this.Resource.sync = function (callback) {
that._design._rev = headers.etag.slice(1, -1);
}
that.connection.put(id, that._design, function (e, res) {
if (e) {/* TODO: Catch errors here. Needs a rewrite, because of the race */}
/* condition, when the design doc is trying to be written in parallel */
if (e) {
if (e.reason === 'no_db_file') {
that.connection.connection.create(function () {
that.sync(callback);
});
}

/* TODO: Catch errors here. Needs a rewrite, because of the race */
/* condition, when the design doc is trying to be written in parallel */
}
else {
// We might not need to wait for the document to be
// persisted, before returning it. If for whatever reason
Expand Down

0 comments on commit 0fd2e47

Please sign in to comment.