mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(rest) callback called on success only -> callback called always
This commit is contained in:
parent
b91aea942b
commit
2b307fe6dd
8 changed files with 58 additions and 44 deletions
|
|
@ -371,7 +371,7 @@ var Util, DOM, CloudFunc, join;
|
|||
if (!isRefresh && json)
|
||||
createFileTable(obj, panel, options, callback);
|
||||
else
|
||||
RESTful.read(path, 'json', function(obj) {
|
||||
RESTful.read(path, 'json', function(error, obj) {
|
||||
createFileTable(obj, panel, options, function() {
|
||||
var current;
|
||||
|
||||
|
|
|
|||
|
|
@ -194,8 +194,9 @@ var CloudCmd, Util, DOM, io;
|
|||
function saveHttp(obj) {
|
||||
var RESTful = DOM.RESTful;
|
||||
|
||||
RESTful.Config.write(obj, function() {
|
||||
onSave(obj);
|
||||
RESTful.Config.write(obj, function(error) {
|
||||
if (!error)
|
||||
onSave(obj);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -457,8 +457,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
path += type;
|
||||
|
||||
if (name)
|
||||
RESTful.write(path, function() {
|
||||
CloudCmd.refresh(null, function() {
|
||||
RESTful.write(path, function(error) {
|
||||
!error && CloudCmd.refresh(null, function() {
|
||||
var current = DOM.getCurrentByName(name);
|
||||
|
||||
DOM.setCurrentFile(current);
|
||||
|
|
@ -514,8 +514,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
Images.show.load('top');
|
||||
|
||||
op(fileFrom, function() {
|
||||
CloudCmd.refresh(null, function() {
|
||||
op(fileFrom, function(error) {
|
||||
!error && CloudCmd.refresh(null, function() {
|
||||
var file = DOM.getCurrentByName(name);
|
||||
|
||||
DOM.setCurrentFile(file);
|
||||
|
|
@ -678,10 +678,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
Images.show.load();
|
||||
|
||||
if (name !== '..')
|
||||
RESTful.read(link + query, function(size) {
|
||||
DOM.setCurrentSize(size, current);
|
||||
Util.exec(callback, current);
|
||||
Images.hide();
|
||||
RESTful.read(link + query, function(error, size) {
|
||||
if (!error) {
|
||||
DOM.setCurrentSize(size, current);
|
||||
Util.exec(callback, current);
|
||||
Images.hide();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -696,9 +698,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
query = '?hash',
|
||||
link = DOM.getCurrentPath(current);
|
||||
|
||||
RESTful.read(link + query, function(data) {
|
||||
callback(null, data);
|
||||
});
|
||||
RESTful.read(link + query, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -766,18 +766,21 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
path = DOM.getCurrentPath(current),
|
||||
isDir = DOM.isCurrentIsDir(current),
|
||||
|
||||
func = function(data) {
|
||||
func = function(error, data) {
|
||||
var length,
|
||||
ONE_MEGABYTE = 1024 * 1024 * 1024;
|
||||
|
||||
if (Util.type.object(data))
|
||||
data = Util.json.stringify(data);
|
||||
if (!error) {
|
||||
if (Util.type.object(data))
|
||||
data = Util.json.stringify(data);
|
||||
|
||||
length = data.length;
|
||||
|
||||
if (hash && length < ONE_MEGABYTE)
|
||||
DOM.saveDataToStorage(path, data, hash);
|
||||
}
|
||||
|
||||
length = data.length;
|
||||
if (hash && length < ONE_MEGABYTE)
|
||||
DOM.saveDataToStorage(path, data, hash);
|
||||
|
||||
Util.exec(callback, null, data);
|
||||
callback(error, data);
|
||||
};
|
||||
|
||||
if (Info.name === '..')
|
||||
|
|
@ -806,8 +809,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
if (!query)
|
||||
query = '';
|
||||
|
||||
DOM.RESTful.write(url + query, data, function() {
|
||||
DOM.saveDataToStorage(url, data);
|
||||
DOM.RESTful.write(url + query, data, function(error) {
|
||||
!error && DOM.saveDataToStorage(url, data);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -1459,16 +1462,18 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
to : dirPath + to
|
||||
};
|
||||
|
||||
RESTful.mv(files, function() {
|
||||
RESTful.mv(files, function(error) {
|
||||
var Storage = DOM.Storage,
|
||||
path = CloudFunc.rmLastSlash(dirPath);
|
||||
|
||||
DOM.setCurrentName(to, current);
|
||||
Cmd.updateCurrentInfo();
|
||||
Storage.remove(path);
|
||||
|
||||
if (isExist)
|
||||
CloudCmd.refresh();
|
||||
if (!error) {
|
||||
DOM.setCurrentName(to, current);
|
||||
Cmd.updateCurrentInfo();
|
||||
Storage.remove(path);
|
||||
|
||||
if (isExist)
|
||||
CloudCmd.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ var CloudCmd, Util, DOM;
|
|||
if (o.relative)
|
||||
name += relativeQuery;
|
||||
|
||||
Markdown.read(name, function(result) {
|
||||
Markdown.read(name, function(error, result) {
|
||||
var div = DOM.load({
|
||||
name : 'div',
|
||||
className : 'help',
|
||||
|
|
|
|||
|
|
@ -265,7 +265,9 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
|
|||
CloudCmd.execFromModule('FilePicker', 'saveFile', function(name, data) {
|
||||
var path = DOM.getCurrentDirPath() + name;
|
||||
|
||||
DOM.RESTful.write(path, data, CloudCmd.refresh);
|
||||
DOM.RESTful.write(path, data, function(error) {
|
||||
!error && CloudCmd.refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,17 +239,19 @@
|
|||
if (!n)
|
||||
names = [Info.name];
|
||||
|
||||
deleteFn(path + query, names, function() {
|
||||
deleteFn(path + query, names, function(error) {
|
||||
var Storage = DOM.Storage,
|
||||
dirPath = Info.dirPath,
|
||||
dir = rmLastSlash(dirPath);
|
||||
|
||||
if (n > 1)
|
||||
DOM.deleteSelected(files);
|
||||
else
|
||||
DOM.deleteCurrent(current);
|
||||
|
||||
Storage.removeMatch(dir);
|
||||
if (!error) {
|
||||
if (n > 1)
|
||||
DOM.deleteSelected(files);
|
||||
else
|
||||
DOM.deleteCurrent(current);
|
||||
|
||||
Storage.removeMatch(dir);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -315,10 +317,10 @@
|
|||
names : names
|
||||
};
|
||||
|
||||
operation(files, function() {
|
||||
operation(files, function(error) {
|
||||
var path = rmLastSlash(from);
|
||||
|
||||
DOM.Storage.remove(path, function() {
|
||||
!error && DOM.Storage.remove(path, function() {
|
||||
var panel = Info.panel,
|
||||
panelPassive = Info.panelPassive,
|
||||
setCurrent = function() {
|
||||
|
|
|
|||
|
|
@ -197,6 +197,8 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
setTimeout(function() {
|
||||
DOM.Dialog.alert(text);
|
||||
}, 100);
|
||||
|
||||
p.callback(Error(text));
|
||||
},
|
||||
success : function(data) {
|
||||
Images.hide();
|
||||
|
|
@ -204,7 +206,7 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
if (!p.notLog)
|
||||
CloudCmd.log(data);
|
||||
|
||||
Util.exec(p.callback, data);
|
||||
p.callback(null, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,9 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
Upload.hide();
|
||||
|
||||
DOM.uploadFiles(files);
|
||||
DOM.uploadFiles(files, function(error) {
|
||||
error && CloudCmd.log(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue