java - Check compressed archive for corruption -


i creating compressed archives tar , bzip2 using jarchivelib utilizes org.apache.commons.compress.

try {     archiver archiver = archiverfactory.createarchiver(archiveformat.tar, compressiontype.bzip2);     file archive = archiver.create(archivename, destination, sourcefilesarr); } catch (ioexception e) {     e.printstacktrace(); } 

sometimes can happen created file corrupted, want check , recreate archive if necessary. there no error thrown , detected corruption when trying decompress manually tar -xf file.tar.bz2 (note: extracting tar -xjf file.tar.bz2 works flawlessly)

tar: archive contains `\2640\003\203\325@\0\0\0\003\336\274' numeric off_t value expected tar: archive contains `\0l`\t\0\021\0' numeric mode_t value expected tar: archive contains `\003\301\345\0\0\0\0\006\361\0p\340' numeric time_t value expected tar: archive contains `\0\210\001\b\0\233\0' numeric uid_t value expected tar: archive contains `l\001\210\0\210\001\263' numeric gid_t value expected tar: bzh91ay&sy"'ݛ\003\314>\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\343\262\037\017\205\360x\001\210: unknown file type `', extracted normal file tar: bzh91ay&sy"'ݛ�>��������������������������������������x�: implausibly old time stamp 1970-01-01 00:59:59 tar: skipping next header tar: exiting failure status due previous errors 

is there way using org.apache.commons.compress check compressed archive if corrupted? since files can @ size of several gb approach without decompressing great.

as bzip2 compression produces stream, there no way how check corruption without decompressing stream , passing tar check.

anyway, in case decompress directly tar , not passing first bzip2. root cause. need use -j flag tar it's compressed bzip2. that's why second command works correctly.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -