Commit 76e021e1 authored by Tristan Cavelier's avatar Tristan Cavelier

Updating Index Storage

parent 0c0dbc06
...@@ -159,7 +159,7 @@ var newIndexStorage = function ( spec, my ) { ...@@ -159,7 +159,7 @@ var newIndexStorage = function ( spec, my ) {
*/ */
priv.update = function () { priv.update = function () {
// retreive list before, and then retreive all files // retreive list before, and then retreive all files
var getlist_onDone = function (result) { var getlist_onSuccess = function (result) {
if (!priv.isAnIndexedStorage(priv.secondstorage_string)) { if (!priv.isAnIndexedStorage(priv.secondstorage_string)) {
priv.indexStorage(priv.secondstorage_string); priv.indexStorage(priv.secondstorage_string);
} }
...@@ -168,7 +168,7 @@ var newIndexStorage = function ( spec, my ) { ...@@ -168,7 +168,7 @@ var newIndexStorage = function ( spec, my ) {
that.addJob ( that.newStorage (priv.secondstorage_spec), that.addJob ( that.newStorage (priv.secondstorage_spec),
that.newCommand ('getDocumentList', that.newCommand ('getDocumentList',
{path:'.', {path:'.',
option:{onDone:getlist_onDone, option:{success:getlist_onSuccess,
max_retry: 3}}) ); max_retry: 3}}) );
}; };
...@@ -178,17 +178,16 @@ var newIndexStorage = function ( spec, my ) { ...@@ -178,17 +178,16 @@ var newIndexStorage = function ( spec, my ) {
*/ */
that.saveDocument = function (command) { that.saveDocument = function (command) {
var newcommand = command.clone(); var newcommand = command.clone();
newcommand.onResponseDo (function(){}); newcommand.onSuccessDo (function (result) {
newcommand.onDoneDo (function (result) {
if (!priv.isFileIndexed(command.getPath())) { if (!priv.isFileIndexed(command.getPath())) {
priv.addFile({name:command.getPath(), priv.addFile({name:command.getPath(),
last_modified:0,creation_date:0}); last_modified:0,creation_date:0});
} }
priv.update(); priv.update();
that.done(); that.success();
}); });
newcommand.onFailDo (function (result) { newcommand.onErrorDo (function (result) {
that.fail(result); that.error(result);
}); });
that.addJob ( that.newStorage(priv.secondstorage_spec), that.addJob ( that.newStorage(priv.secondstorage_spec),
newcommand ); newcommand );
...@@ -200,7 +199,7 @@ var newIndexStorage = function ( spec, my ) { ...@@ -200,7 +199,7 @@ var newIndexStorage = function ( spec, my ) {
*/ */
that.loadDocument = function (command) { that.loadDocument = function (command) {
var file_array, i, l, new_job, var file_array, i, l, new_job,
loadOnDone = function (result) { loadOnSuccess = function (result) {
// if (file_array[i].last_modified !== // if (file_array[i].last_modified !==
// result.return_value.last_modified || // result.return_value.last_modified ||
// file_array[i].creation_date !== // file_array[i].creation_date !==
...@@ -209,16 +208,15 @@ var newIndexStorage = function ( spec, my ) { ...@@ -209,16 +208,15 @@ var newIndexStorage = function ( spec, my ) {
// // the one in the second storage. priv.update will // // the one in the second storage. priv.update will
// // take care of refresh the indexed storage // // take care of refresh the indexed storage
// } // }
that.done(result); that.success(result);
}, },
loadOnFail = function (result) { loadOnError = function (result) {
that.fail(result); that.error(result);
}, },
secondLoadDocument = function () { secondLoadDocument = function () {
var newcommand = command.clone(); var newcommand = command.clone();
newcommand.onResponseDo (function(){}); newcommand.onErrorDo (loadOnError);
newcommand.onFailDo (loadOnFail); newcommand.onSuccessDo (loadOnSuccess);
newcommand.onDoneDo (loadOnDone);
that.addJob ( that.newStorage(priv.secondstorage_spec), that.addJob ( that.newStorage(priv.secondstorage_spec),
newcommand ); newcommand );
}; };
...@@ -229,7 +227,7 @@ var newIndexStorage = function ( spec, my ) { ...@@ -229,7 +227,7 @@ var newIndexStorage = function ( spec, my ) {
file_array = priv.getFileArray(); file_array = priv.getFileArray();
for (i = 0, l = file_array.length; i < l; i+= 1) { for (i = 0, l = file_array.length; i < l; i+= 1) {
if (file_array[i].name === command.getPath()) { if (file_array[i].name === command.getPath()) {
return that.done(file_array[i]); return that.success(file_array[i]);
} }
} }
} else { } else {
...@@ -251,12 +249,12 @@ var newIndexStorage = function ( spec, my ) { ...@@ -251,12 +249,12 @@ var newIndexStorage = function ( spec, my ) {
if (command.getOption('metadata_only')) { if (command.getOption('metadata_only')) {
id = setInterval(function () { id = setInterval(function () {
if (timeout) { if (timeout) {
that.fail({status:0,statusText:'Timeout', that.error({status:0,statusText:'Timeout',
message:'The request has timed out.'}); message:'The request has timed out.'});
clearInterval(id); clearInterval(id);
} }
if (priv.fileArrayExists()) { if (priv.fileArrayExists()) {
that.done(priv.getFileArray()); that.success(priv.getFileArray());
clearInterval(id); clearInterval(id);
} }
},100); },100);
...@@ -265,11 +263,11 @@ var newIndexStorage = function ( spec, my ) { ...@@ -265,11 +263,11 @@ var newIndexStorage = function ( spec, my ) {
}, 10000); // 10 sec }, 10000); // 10 sec
} else { } else {
newcommand = command.clone(); newcommand = command.clone();
newcommand.onDoneDo (function (result) { newcommand.onSuccessDo (function (result) {
that.done(result); that.success(result);
}); });
newcommand.onFailDo (function (result) { newcommand.onErrorDo (function (result) {
that.fail(result); that.error(result);
}); });
that.addJob ( that.newStorage (priv.secondstorage_spec), that.addJob ( that.newStorage (priv.secondstorage_spec),
newcommand ); newcommand );
...@@ -282,14 +280,13 @@ var newIndexStorage = function ( spec, my ) { ...@@ -282,14 +280,13 @@ var newIndexStorage = function ( spec, my ) {
*/ */
that.removeDocument = function (command) { that.removeDocument = function (command) {
var newcommand = command.clone(); var newcommand = command.clone();
newcommand.onResponseDo (function(){}); newcommand.onSuccessDo (function (result) {
newcommand.onDoneDo (function (result) {
priv.removeFile(command.getPath()); priv.removeFile(command.getPath());
priv.update(); priv.update();
that.done(); that.success();
}); });
newcommand.onFailDo (function (result) { newcommand.onErrorDo (function (result) {
that.fail(result); that.error(result);
}); });
that.addJob( that.newStorage(priv.secondstorage_spec), that.addJob( that.newStorage(priv.secondstorage_spec),
newcommand ); newcommand );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment