mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-08 14:19:32 +00:00
Merge remote-tracking branch 'upstream/develop' into collaborative
This commit is contained in:
commit
1e5d66332a
@ -502,7 +502,10 @@ class SevenZipExtractor {
|
|||||||
SevenZipExtractor.UnpackStream unpackStream = null;
|
SevenZipExtractor.UnpackStream unpackStream = null;
|
||||||
if (!isDir) {
|
if (!isDir) {
|
||||||
try {
|
try {
|
||||||
unpackStream = new SevenZipExtractor.UnpackStream(localAbsPath, freeDiskSpace, size == null);
|
if (size != null)
|
||||||
|
unpackStream = new SevenZipExtractor.KnownSizeUnpackStream(localAbsPath, size);
|
||||||
|
else
|
||||||
|
unpackStream = new SevenZipExtractor.UnknownSizeUnpackStream(localAbsPath, freeDiskSpace);
|
||||||
item.extractSlow(unpackStream);
|
item.extractSlow(unpackStream);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//could be something unexpected with this file, move on
|
//could be something unexpected with this file, move on
|
||||||
@ -510,22 +513,14 @@ class SevenZipExtractor {
|
|||||||
} finally {
|
} finally {
|
||||||
if (unpackStream != null) {
|
if (unpackStream != null) {
|
||||||
//record derived data in unode, to be traversed later after unpacking the archive
|
//record derived data in unode, to be traversed later after unpacking the archive
|
||||||
if (size != null) {
|
unpackedNode.addDerivedInfo(unpackStream.getSize(), !isDir,
|
||||||
// unpackedNode.bytesWritten will not be set in
|
|
||||||
// this case. Use 'size' which has been set
|
|
||||||
// previously.
|
|
||||||
unpackedNode.addDerivedInfo(size, !isDir,
|
|
||||||
0L, createtime, accesstime, modtime, localRelPath);
|
0L, createtime, accesstime, modtime, localRelPath);
|
||||||
} else {
|
|
||||||
// since size is unknown, use
|
|
||||||
// unpackStream.getNumberOfBytesWritten() to get
|
|
||||||
// the size.
|
|
||||||
unpackedNode.addDerivedInfo(unpackStream.getNumberOfBytesWritten(), !isDir,
|
|
||||||
0L, createtime, accesstime, modtime, localRelPath);
|
|
||||||
}
|
|
||||||
unpackStream.close();
|
unpackStream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else { // this is a directory, size is always 0
|
||||||
|
unpackedNode.addDerivedInfo(0, !isDir,
|
||||||
|
0L, createtime, accesstime, modtime, localRelPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//update units for progress bar
|
//update units for progress bar
|
||||||
@ -615,18 +610,12 @@ class SevenZipExtractor {
|
|||||||
/**
|
/**
|
||||||
* Stream used to unpack the archive to local file
|
* Stream used to unpack the archive to local file
|
||||||
*/
|
*/
|
||||||
private static class UnpackStream implements ISequentialOutStream {
|
private abstract static class UnpackStream implements ISequentialOutStream {
|
||||||
|
|
||||||
private OutputStream output;
|
private OutputStream output;
|
||||||
private String localAbsPath;
|
private String localAbsPath;
|
||||||
private long freeDiskSpace;
|
|
||||||
private boolean sizeUnknown = false;
|
|
||||||
private boolean outOfSpace = false;
|
|
||||||
private long bytesWritten = 0;
|
|
||||||
|
|
||||||
UnpackStream(String localAbsPath, long freeDiskSpace, boolean sizeUnknown) {
|
UnpackStream(String localAbsPath) {
|
||||||
this.sizeUnknown = sizeUnknown;
|
|
||||||
this.freeDiskSpace = freeDiskSpace;
|
|
||||||
this.localAbsPath = localAbsPath;
|
this.localAbsPath = localAbsPath;
|
||||||
try {
|
try {
|
||||||
output = new BufferedOutputStream(new FileOutputStream(localAbsPath));
|
output = new BufferedOutputStream(new FileOutputStream(localAbsPath));
|
||||||
@ -636,21 +625,55 @@ class SevenZipExtractor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getNumberOfBytesWritten() {
|
public abstract long getSize();
|
||||||
|
|
||||||
|
OutputStream getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getLocalAbsPath() {
|
||||||
|
return localAbsPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (output != null) {
|
||||||
|
try {
|
||||||
|
output.flush();
|
||||||
|
output.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.log(Level.SEVERE, "Error closing unpack stream for file: {0}", localAbsPath); //NON-NLS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream used to unpack the archive of unknown size to local file
|
||||||
|
*/
|
||||||
|
private static class UnknownSizeUnpackStream extends UnpackStream {
|
||||||
|
|
||||||
|
private long freeDiskSpace;
|
||||||
|
private boolean outOfSpace = false;
|
||||||
|
private long bytesWritten = 0;
|
||||||
|
|
||||||
|
UnknownSizeUnpackStream(String localAbsPath, long freeDiskSpace) {
|
||||||
|
super(localAbsPath);
|
||||||
|
this.freeDiskSpace = freeDiskSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() {
|
||||||
return this.bytesWritten;
|
return this.bytesWritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int write(byte[] bytes) throws SevenZipException {
|
public int write(byte[] bytes) throws SevenZipException {
|
||||||
try {
|
try {
|
||||||
if (!sizeUnknown) {
|
|
||||||
output.write(bytes);
|
|
||||||
} else {
|
|
||||||
// If the content size is unknown, cautiously write to disk.
|
// If the content size is unknown, cautiously write to disk.
|
||||||
// Write only if byte array is less than 80% of the current
|
// Write only if byte array is less than 80% of the current
|
||||||
// free disk space.
|
// free disk space.
|
||||||
if (freeDiskSpace == IngestMonitor.DISK_FREE_SPACE_UNKNOWN || bytes.length < 0.8 * freeDiskSpace) {
|
if (freeDiskSpace == IngestMonitor.DISK_FREE_SPACE_UNKNOWN || bytes.length < 0.8 * freeDiskSpace) {
|
||||||
output.write(bytes);
|
getOutput().write(bytes);
|
||||||
// NOTE: this method is called multiple times for a
|
// NOTE: this method is called multiple times for a
|
||||||
// single extractSlow() call. Update bytesWritten and
|
// single extractSlow() call. Update bytesWritten and
|
||||||
// freeDiskSpace after every write operation.
|
// freeDiskSpace after every write operation.
|
||||||
@ -664,30 +687,60 @@ class SevenZipExtractor {
|
|||||||
throw new SevenZipException(
|
throw new SevenZipException(
|
||||||
NbBundle.getMessage(SevenZipExtractor.class, "EmbeddedFileExtractorIngestModule.ArchiveExtractor.UnpackStream.write.noSpace.msg"));
|
NbBundle.getMessage(SevenZipExtractor.class, "EmbeddedFileExtractorIngestModule.ArchiveExtractor.UnpackStream.write.noSpace.msg"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new SevenZipException(
|
throw new SevenZipException(
|
||||||
NbBundle.getMessage(SevenZipExtractor.class, "EmbeddedFileExtractorIngestModule.ArchiveExtractor.UnpackStream.write.exception.msg",
|
NbBundle.getMessage(SevenZipExtractor.class, "EmbeddedFileExtractorIngestModule.ArchiveExtractor.UnpackStream.write.exception.msg",
|
||||||
localAbsPath), ex);
|
getLocalAbsPath()), ex);
|
||||||
}
|
}
|
||||||
return bytes.length;
|
return bytes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
if (output != null) {
|
if (getOutput() != null) {
|
||||||
try {
|
try {
|
||||||
output.flush();
|
getOutput().flush();
|
||||||
output.close();
|
getOutput().close();
|
||||||
if (this.outOfSpace) {
|
if (this.outOfSpace) {
|
||||||
Files.delete(Paths.get(this.localAbsPath));
|
Files.delete(Paths.get(getLocalAbsPath()));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.log(Level.SEVERE, "Error closing unpack stream for file: {0}", localAbsPath); //NON-NLS
|
logger.log(Level.SEVERE, "Error closing unpack stream for file: {0}", getLocalAbsPath()); //NON-NLS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream used to unpack the archive of known size to local file
|
||||||
|
*/
|
||||||
|
private static class KnownSizeUnpackStream extends UnpackStream {
|
||||||
|
|
||||||
|
private long size;
|
||||||
|
|
||||||
|
KnownSizeUnpackStream(String localAbsPath, long size) {
|
||||||
|
super(localAbsPath);
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() {
|
||||||
|
return this.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int write(byte[] bytes) throws SevenZipException {
|
||||||
|
try {
|
||||||
|
getOutput().write(bytes);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new SevenZipException(
|
||||||
|
NbBundle.getMessage(SevenZipExtractor.class, "EmbeddedFileExtractorIngestModule.ArchiveExtractor.UnpackStream.write.exception.msg",
|
||||||
|
getLocalAbsPath()), ex);
|
||||||
|
}
|
||||||
|
return bytes.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of the files in the archive. Used to track of local tree
|
* Representation of the files in the archive. Used to track of local tree
|
||||||
* file hierarchy, archive depth, and files created to easily and reliably
|
* file hierarchy, archive depth, and files created to easily and reliably
|
||||||
|
@ -552,7 +552,7 @@ SORT_MEMBER_DOCS = YES
|
|||||||
# this will also influence the order of the classes in the class list.
|
# this will also influence the order of the classes in the class list.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
SORT_BRIEF_DOCS = NO
|
SORT_BRIEF_DOCS = YES
|
||||||
|
|
||||||
# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
|
# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
|
||||||
# (brief and detailed) documentation of class members so that constructors and
|
# (brief and detailed) documentation of class members so that constructors and
|
||||||
@ -564,14 +564,14 @@ SORT_BRIEF_DOCS = NO
|
|||||||
# detailed member documentation.
|
# detailed member documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
SORT_MEMBERS_CTORS_1ST = NO
|
SORT_MEMBERS_CTORS_1ST = YES
|
||||||
|
|
||||||
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
|
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
|
||||||
# of group names into alphabetical order. If set to NO the group names will
|
# of group names into alphabetical order. If set to NO the group names will
|
||||||
# appear in their defined order.
|
# appear in their defined order.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
SORT_GROUP_NAMES = NO
|
SORT_GROUP_NAMES = YES
|
||||||
|
|
||||||
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
|
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
|
||||||
# fully-qualified names, including namespaces. If set to NO, the class list will
|
# fully-qualified names, including namespaces. If set to NO, the class list will
|
||||||
|
@ -256,10 +256,16 @@ class PstParser {
|
|||||||
int bufferSize = 8176;
|
int bufferSize = 8176;
|
||||||
byte[] buffer = new byte[bufferSize];
|
byte[] buffer = new byte[bufferSize];
|
||||||
int count = attachmentStream.read(buffer);
|
int count = attachmentStream.read(buffer);
|
||||||
|
|
||||||
|
if(count == -1) {
|
||||||
|
throw new IOException("attachmentStream invalid (read() fails). File "+attach.getLongFilename()+ " skipped");
|
||||||
|
}
|
||||||
|
|
||||||
while (count == bufferSize) {
|
while (count == bufferSize) {
|
||||||
out.write(buffer);
|
out.write(buffer);
|
||||||
count = attachmentStream.read(buffer);
|
count = attachmentStream.read(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] endBuffer = new byte[count];
|
byte[] endBuffer = new byte[count];
|
||||||
System.arraycopy(buffer, 0, endBuffer, 0, count);
|
System.arraycopy(buffer, 0, endBuffer, 0, count);
|
||||||
out.write(endBuffer);
|
out.write(endBuffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user