Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tFileUnarchive - How to know if the zip is invalid or has no entries?

Hello,
I have a question concerning the tFileUnarchiveComponent.  I'm using it on some zip files, some of which may be invalid and some of which may have no entries.  I would like to link to a component when an invalid zip file is encountered and I'd like to know if there are no rows (ie. no files) from a particular zip.
(Surprisingly, the onComponentError flow is not activated when there is an invalid zip.)
I'd be very grateful for any links to solutions or ideas for alternatives...
Thanks!
Labels (2)
16 Replies
Anonymous
Not applicable
Author

I use any file that is not a zip file (e.g. the one attached).  The tFileUnarchive component logs "archive is not a ZIP archive" when "Check the integrity before unzip" is unchecked.  When that option is checked then I get "The file C:/tools/talend_workspace/archive.zip is corrupted, process terminated...".
In neither case does the OnComponentError get triggered.
archive.zip_20160822-0440.zip
Anonymous
Not applicable
Author

Hi,
The attachment you provided is not avaliable on talend forum. Could you please take a look at it?
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi,
The zip may have been blocked by my firewall.  It doesn't matter, you can use any file that is not a zip file e.g. Take a jpg and rename it .zip to obtain an invalid zip file.  When you try to unzip it with the tFileUnarchive component you will get the behavior described in my previous post i.e. OnComponentError does not get triggered.
Best,
François
David_Beaty
Specialist
Specialist

Hi Francois,

 

I don't think the tFileUnarchive component, as standard, will allow you to do what you want. The only semi-sensible solution I could come up with, was to enable the "Use archive file name as root directory" option, then once the component has unzipped the archive, successfully or not, is to then check the number of files in the resulting sub-directory. If this is 0, then the archive was corrupt/unzippable.

 

Thanks

 

David

Anonymous
Not applicable
Author

Old thread, but I had a similar issue.  Solved it by using an iterate.  Since tFileUnarchive will only iterate if it unzips something, you can hang a tJava off of it, and set some variable like "GoodZip" which then only gets set if it found unzipped at least one file.

offcourse2
Contributor
Contributor

Hi all

 

I still have the same issue, and can't find my way around it. Althouth the iterate solution seems to work, it has two problems:

  1. It will run whatever comes next as many times as the number of files you have found inside the zip file. Eg. If next step is to create a file and send an email, it will do it 200 times if the zip file has 200 files inside
  2. It doesn't allow me to be warned if the zip file is corrupt, so I can go and solve whatever is wrong.

 

In my case, I am downloading a zip file from and FTP server, extracting the content, processing a json file which is inside and then creating and emailing an excel file. Now, if the zip file is corrupted, I have no view of that, which is what I am after.

 

Any new ideas?

 

Thanks

Anonymous
Not applicable
Author

@offcourse2 -- you're correct. 

 

For #1, I solved this by hanging a tJava off of the iterate that sets a "GoodZip" global variable to true.  It doesn't matter whether that sets it to true 200 times.  You can then hang your real logic off of a RunIf that checks for the GoodZip variable, and it will only run once.

 

For #2, maybe you create another RunIf where if the zip file exists, but "GoodZip" is false (i.e. it never iterated), than the file must be corrupt.  Just a thought.