mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 08:54:10 +00:00
feature(edit) rm client sha
This commit is contained in:
parent
c94515d0a2
commit
1b47867f9c
5 changed files with 18 additions and 389 deletions
|
|
@ -1781,30 +1781,24 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* @param data
|
||||
* @param callback
|
||||
*/
|
||||
this.saveDataToStorage = function(name, data, hash, callback) {
|
||||
this.saveDataToStorage = function(name, data, callback) {
|
||||
CloudCmd.getConfig(function(config) {
|
||||
var allowed = config.localStorage,
|
||||
isDir = DOM.isCurrentIsDir(),
|
||||
nameHash = name + '-hash',
|
||||
nameData = name + '-data',
|
||||
save = function(hash) {
|
||||
Storage.set(nameHash, hash);
|
||||
Storage.set(nameData, data);
|
||||
};
|
||||
nameData = name + '-data';
|
||||
|
||||
if (!allowed || isDir)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
if (hash)
|
||||
save(hash);
|
||||
else
|
||||
DOM.checkStorageHash(name, function(error, equal, hash) {
|
||||
if (!error && !equal)
|
||||
save(hash);
|
||||
|
||||
Util.exec(callback, hash);
|
||||
});
|
||||
}
|
||||
else
|
||||
DOM.checkStorageHash(name, function(error, equal, hash) {
|
||||
if (!error && !equal) {
|
||||
Storage.set(nameHash, hash);
|
||||
Storage.set(nameData, data);
|
||||
}
|
||||
|
||||
Util.exec(callback, hash);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
|
|||
Value,
|
||||
Edit = this,
|
||||
Diff,
|
||||
SHA,
|
||||
Ace,
|
||||
Msg,
|
||||
Dialog = DOM.Dialog,
|
||||
|
|
@ -161,20 +160,12 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
|
|||
}
|
||||
|
||||
DOM.checkStorageHash(lPath, function(error, equal) {
|
||||
var ret,
|
||||
msg = 'File is changed, overwrite?',
|
||||
saveFunc = function(text) {
|
||||
var hash = SHA.digest(Value);
|
||||
onSave(text, hash);
|
||||
};
|
||||
|
||||
if (!error && !equal)
|
||||
ret = Dialog.confirm(msg);
|
||||
else
|
||||
DOM.RESTful.save(lPath, lValue, saveFunc, query);
|
||||
if (!error) {
|
||||
if (!equal)
|
||||
query = '';
|
||||
|
||||
if (ret)
|
||||
DOM.RESTful.save(lPath, lValue, saveFunc);
|
||||
DOM.RESTful.save(lPath, lValue, onSave, query);
|
||||
}
|
||||
});
|
||||
|
||||
}, function(callback) {
|
||||
|
|
@ -188,16 +179,12 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
|
|||
function diff(pNewValue, pCallBack) {
|
||||
var libs = [
|
||||
LIBDIR + 'diff.js',
|
||||
LIBDIR + 'diff/diff-match-patch.js',
|
||||
LIBDIR + 'sha1/rusha.js'
|
||||
LIBDIR + 'diff/diff-match-patch.js'
|
||||
];
|
||||
|
||||
DOM.anyLoadInParallel(libs, function() {
|
||||
var patch;
|
||||
|
||||
if (!SHA)
|
||||
SHA = new Rusha();
|
||||
|
||||
if (!Diff)
|
||||
Diff = new DiffProto(diff_match_patch);
|
||||
|
||||
|
|
@ -243,7 +230,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
|
|||
|
||||
if (!isError) {
|
||||
Edit.showMessage(text);
|
||||
DOM.saveDataToStorage(path, Value, hash);
|
||||
DOM.saveDataToStorage(path, Value);
|
||||
} else {
|
||||
ret = Dialog.confirm(text + msg);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue