Smart archive extraction (enhanced)

Thank you so much for this enhanced button.

This works beautifully, thanks!

image
I face a problem with the Enhanced button. when I have Select 100+ RAR file for extract, but some of the file has displayed this kind of error....... the archive appears to be invalid or damaged; Then I Click on Skip. So the file does not be extracted (because it has some problem) and the file also deleted. Because before from here I have selected Delete All Archives.
Destination
So I want If some file have problem for proper extract then Those file should not be Deleted even I select Delete All Archives. Because this delete; I don't get a 2nd chance to repair those problematic archive file

1 Like

Thank you for this hint. I did not consider a failing extractation.

Does someone has a hint how I can include a check regarding this "skip"?
I think I have to add something in the IF clause and a specific variable must have a specific value.

Also the abort should I consider to abort the whole extractation.

But how do I get the return value from this dialog?

Items in the Command's file list should have their failed properties set if they failed.

The script uses Copy FILE=... EXTRACT, so cmd.files will remain empty, I am afraid.

cmd.results.result will only be zero, if the extraction gets aborted, not if the file gets skipped.

Tricky!

Well, if I remember correctly, a warning and good advice were given... :slight_smile:

1 Like

Ok. Is it not possible to check if this error message is shown?
The dialog will also return return values, right?

If you replace this style

cmd.RunCommand('Copy EXTRACT=sub FILE="D:\\error2.rar"');

with this

cmd.ClearFiles();
cmd.AddFile('D:\\error2.rar');
cmd.RunCommand('Copy EXTRACT=sub');

cmd.files(0).failed will be false, if the extraction was ok, and true in all other cases.

At least so it seems :wink:

If you want to test more:

function OnClick(clickData) {
    var cmd = clickData.func.command;
    cmd.deselect = false;

    DOpus.ClearOutput();
    cmd.RunCommand('Set UTILITY=otherlog');

    // cmd.RunCommand('Copy EXTRACT=sub FILE="D:\\error2.rar"');

    cmd.ClearFiles();
    cmd.AddFile('D:\\error2.rar');
    cmd.RunCommand('Copy EXTRACT=sub');

    DOpus.Output('cmd.files.count =     ' + cmd.files.count);
    DOpus.Output('cmd.files(0).failed = ' + cmd.files(0).failed);
    DOpus.Output('cmd.results.result =  ' + cmd.results.result);
}
2 Likes

@lxp: thank you

@khalidhosain Please try this one in a test environment (perhaps you can send me a damaged archive, because I do not have one):
Extract.dcf (38.6 KB)

1 Like

Thanks Mosed I had tested the updated button. now damaged file doesn't delete

Here a damaged file link: Download Here

Here another issue; some files have password. when I select 100+ files for extract that time I want to skip or abort the password protected files. maybe I can't remember the password, or don't know the password or some other reason I have to skip or abort. The updated Extract button have delete the original rar files in skip or abort both case. Here is a Password Protected files

Thank you for the files. Quite big... :smiley:

Edit: for me both files are damaged. No password dialog visible.
But I created an own password protected zip and it gets deleted even when it is skiped. But cmd.files(0).failed is "false".

So the extract is successul, but then canceled. The subdirectory is also created, but empty.

Is it possible to check if an archive is password protected? I guess the easiest solution is to not delete such archives in any case.

Edit 2: If you use the extract all command in the contect menu for a password protected archive the whole process simply fails. Is that a bug?
If you use the submenu regarding extraction Dopus tries to extract and if you skip the newly created subfolder is deleted.

1 Like

Do I see it right that files and folders inside of an archive have th attribute "e"?
Then one idea would be to check for this attribute inside of the archives.

Depending on how the archive was created, it may fail to list entirely without a password. It's optional whether the file list and data are both encrypted, or only the data and not the list.

But that gives also a hint. If the content cannot be listed the archive is encrypted (or damaged).

So perhaps that is the solution? I list internally the content of the archive. If the listing fails or there is a file/folder inside with attribute "e" the archive will not be deleted.
I only have to check how to do that. :slight_smile:

Edit: Ah, when the archive itself is encrypted (created a 7z) the extract fails and the archive will not be deleted (with the new beta-version).

1 Like

With this code snippet I can check if a file inside of the archive is encrypted:

var folderEnum = fsu.ReadDir(item);
var folderItem = folderEnum.Next();

	if (folderItem.fileattr.e) {
		DOpus.Output("Encrypted")
	}
	else {
		DOpus.Output("Not Encrypted" + folderItem.fileattr)
	}

But when I run this on an archive where the file list is also encrypted I get the error message:

'fileattr.e' is null or no object (0x800a138f)

So I added a check if the folderEnum is successful:

if (folderEnum.error === "0"){
	if (folderItem.fileattr.e) {
		DOpus.Output("Encrypted")
	}
	else {
		DOpus.Output("Not Encrypted" + folderItem.fileattr)
	}
}
else {
	DOpus.Output(folderEnum.error)
}

folderEnum.error is "5" in this case (only for information).

But for not encrypted archives (or archives with encrypted files inside) the error code is 18 and not 0. Why is the enumeration not successfull in this case?

Seems that I have to avoid to check for folderItem.fileattr.e if the file list is also encrypted.

The error number should usually only be checked if there's actually an error (i.e. if something fails, it tells you more about why, but otherwise its value doesn't mean much and could even indicate the most recent failure, not the result of the last request if the last request succeeded).

(In this case 18 comes from the API itself, and is ERROR_NO_MORE_FILES which is a Windows error code that means the underlying operation succeed and has run out of files to give back. Keep in mind that ERROR_SUCCESS is also an "error" code. While most of the codes indicate errors, it's more a result or state than an error in general.)

ok. thank you.

The idea behing was: When the file list is encrypted the enumeration will fail. So I can avoid that the script tries to check for folderItem.fileattr.e.

Changed the code line in a first step to

if (folderEnum.error == "0" || folderEnum.error == "18") {

But is perhaps not the best solution.

If you're getting an error that fileattr is null, why not check for that?

1 Like