Skip to content

Commit

Permalink
[cmd:extract] fix #3252 for checking the existence of existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Jun 11, 2021
1 parent 2b7c837 commit f29aa16
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions js/commands/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ elFinder.prototype.commands.extract = function() {
fm = self.fm,
mimes = [],
filter = function(files) {
var fres = true;
return $.grep(files, function(file) {
return file.read && $.inArray(file.mime, mimes) !== -1 ? true : false;
fres = fres && file.read && $.inArray(file.mime, mimes) !== -1 ? true : false;
return fres;
});
};

Expand All @@ -31,9 +33,20 @@ elFinder.prototype.commands.extract = function() {

this.getstate = function(select) {
var sel = this.files(select),
cnt = sel.length;

return cnt && this.fm.cwd().write && filter(sel).length == cnt ? 0 : -1;
cnt = sel.length,
cwdHash, cwdChk;
if (!cnt || filter(sel).length != cnt) {
return -1;
} else if (fm.searchStatus.state > 0) {
cwdHash = this.fm.cwd().hash;
$.each(sel, function(i, file) {
cwdChk = (file.phash === cwdHash);
return cwdChk;
});
return cwdChk? 0 : -1;
} else {
return this.fm.cwd().write? 0 : -1;
}
};

this.exec = function(hashes, opts) {
Expand All @@ -42,17 +55,19 @@ elFinder.prototype.commands.extract = function() {
cnt = files.length,
makedir = opts && opts.makedir ? 1 : 0,
i, error,
decision;
decision,

overwriteAll = false,
omitAll = false,
mkdirAll = 0,
siblings = fm.files(files[0].phash),

var overwriteAll = false;
var omitAll = false;
var mkdirAll = 0;
names = [],
map = {};

var names = $.map(fm.files(hashes), function(file) { return file.name; });
var map = {};
$.grep(fm.files(hashes), function(file) {
$.each(siblings, function(id, file) {
map[file.name] = file;
return false;
names.push(file.name);
});

var decide = function(decision) {
Expand Down

0 comments on commit f29aa16

Please sign in to comment.