aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-04-28 19:08:13 +0400
committerIgor Pashev <pashev.igor@gmail.com>2012-04-28 19:08:13 +0400
commitd40220c1df37d5b981250880dc3043c38bca53d0 (patch)
tree0eb81f3dc1fdbd87e7f82b166de6d77247fa2d07
parent08bd9c3007c69b3c88d2b11dbba904394d9b680f (diff)
downloadnode-augeas-d40220c1df37d5b981250880dc3043c38bca53d0.tar.gz
Async save passes the return value of aug_save(): 0 on success, -1 on failure
-rw-r--r--examples/async-write-etc-hosts.js6
-rw-r--r--libaugeas.cc6
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/async-write-etc-hosts.js b/examples/async-write-etc-hosts.js
index 70640ab..41ad38c 100644
--- a/examples/async-write-etc-hosts.js
+++ b/examples/async-write-etc-hosts.js
@@ -5,14 +5,14 @@ var aug = require('../build/Release/libaugeas');
// but for the goodness sake we set AUG_SAVE_NEWFILE flag here,
// so your /etc/hosts will be kept untouched :-)
aug.createAugeas(
- {lens: 'hosts', incl: '/etc/hosts', flags:aug.AUG_SAVE_NEWFILE},
+ {lens: 'hosts', incl: '/etc/hosts', flags: aug.AUG_SAVE_NEWFILE},
function(aug) {
if (!aug.error()) {
console.log('Making changes ...');
aug.set('/files/etc/hosts/1/ipaddr', '127.0.0.2');
aug.set('/files/etc/hosts/1/canonical', 'localhost');
- aug.save(function(success) {
- if (success) {
+ aug.save(function(err) {
+ if (!err) {
console.log('Saved! Take a look at /etc/hosts.augnew');
} else {
console.log('Failed :-( Here is the reason:');
diff --git a/libaugeas.cc b/libaugeas.cc
index 2bbafec..17080c5 100644
--- a/libaugeas.cc
+++ b/libaugeas.cc
@@ -556,7 +556,7 @@ void saveAfter(uv_work_t* req)
HandleScope scope;
SaveUV *suv = static_cast<SaveUV*>(req->data);
- Local<Value> argv[] = {Local<Boolean>::New(Boolean::New(0 == suv->rc))};
+ Local<Value> argv[] = {Integer::New(suv->rc)};
TryCatch try_catch;
suv->callback->Call(Context::GetCurrent()->Global(), 1, argv);
@@ -581,8 +581,8 @@ void saveAfter(uv_work_t* req)
* The only argument allowed is a callback function.
* If such an argument is given this function performs
* non-blocking (async) saving, and after saving is done (or failed)
- * executes the callback with one boolean argument: true on success saving
- * and false on failure.
+ * executes the callback with one integer argument - return value of aug_save(),
+ * i. e. 0 on success, -1 on failure.
*
* NOTE: multiple async calls of this function (from the same augeas object)
* will result in crash (double free or segfault) because of using