mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
refactor(dom) checkStorageHash
This commit is contained in:
parent
bcedc6b7b5
commit
1f533b9eeb
1 changed files with 23 additions and 18 deletions
|
|
@ -702,11 +702,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
*/
|
||||
this.loadCurrentHash = function(callback, currentFile) {
|
||||
var RESTful = DOM.RESTful,
|
||||
current = currentFile || this.getCurrentFile(),
|
||||
current = currentFile || DOM.getCurrentFile(),
|
||||
query = '?hash',
|
||||
link = this.getCurrentPath(current);
|
||||
link = DOM.getCurrentPath(current);
|
||||
|
||||
RESTful.read(link + query, callback);
|
||||
RESTful.read(link + query, function(data) {
|
||||
callback(null, data);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1185,21 +1187,24 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* check storage hash
|
||||
*/
|
||||
this.checkStorageHash = function(name, callback) {
|
||||
DOM.loadCurrentHash(function(loadHash) {
|
||||
var Storage = DOM.Storage,
|
||||
nameHash = name + '-hash';
|
||||
var Storage = DOM.Storage,
|
||||
parallel = Util.exec.parallel,
|
||||
loadHash = DOM.loadCurrentHash,
|
||||
nameHash = name + '-hash',
|
||||
getStoreHash = Util.exec.with(Storage.get, nameHash);
|
||||
|
||||
Util.checkArgs(arguments, ['name', 'callback']);
|
||||
|
||||
parallel([loadHash, getStoreHash], function(error, loadHash, storeHash) {
|
||||
var equal,
|
||||
isContain = Util.isContainStr(loadHash, 'error');
|
||||
|
||||
Storage.get(nameHash, function(error, storeHash) {
|
||||
var equal,
|
||||
isContain = Util.isContainStr(loadHash, 'error');
|
||||
|
||||
if (isContain)
|
||||
error = loadHash;
|
||||
else if (loadHash === storeHash)
|
||||
equal = true;
|
||||
|
||||
Util.exec(callback, error, equal, loadHash);
|
||||
});
|
||||
if (isContain)
|
||||
error = loadHash;
|
||||
else if (loadHash === storeHash)
|
||||
equal = true;
|
||||
|
||||
callback(error, equal, loadHash);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -1228,7 +1233,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
Util.exec(callback, hash);
|
||||
}, function(callback) {
|
||||
DOM.loadCurrentHash(function(loadHash) {
|
||||
DOM.loadCurrentHash(function(error, loadHash) {
|
||||
hash = loadHash;
|
||||
callback();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue