Unzip: adjust error reporting mechanism
Don’t use local exception throw+catch to report failures in extracting a zip archive, since this generates noise in Sentry.
This commit is contained in:
parent
8fdc1d306f
commit
e1fe9b45e0
@ -511,32 +511,34 @@ public:
|
|||||||
const size_t BUFFER_SIZE = 1024 * 1024;
|
const size_t BUFFER_SIZE = 1024 * 1024;
|
||||||
void* buf = malloc(BUFFER_SIZE);
|
void* buf = malloc(BUFFER_SIZE);
|
||||||
|
|
||||||
try {
|
int result = unzGoToFirstFile(zip);
|
||||||
int result = unzGoToFirstFile(zip);
|
if (result != UNZ_OK) {
|
||||||
if (result != UNZ_OK) {
|
SG_LOG(SG_IO, SG_ALERT, outer->rootPath() << "failed to go to first file in archive:" << result);
|
||||||
throw sg_exception("failed to go to first file in archive");
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
extractCurrentFile(zip, (char*)buf, BUFFER_SIZE);
|
|
||||||
if (state == FILTER_STOPPED) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = unzGoToNextFile(zip);
|
|
||||||
if (result == UNZ_END_OF_LIST_OF_FILE) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (result != UNZ_OK) {
|
|
||||||
throw sg_io_exception("failed to go to next file in the archive");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state = END_OF_ARCHIVE;
|
|
||||||
}
|
|
||||||
catch (sg_exception&) {
|
|
||||||
state = BAD_ARCHIVE;
|
state = BAD_ARCHIVE;
|
||||||
|
free(buf);
|
||||||
|
unzClose(zip);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
extractCurrentFile(zip, (char*)buf, BUFFER_SIZE);
|
||||||
|
if (state == FILTER_STOPPED) {
|
||||||
|
state = END_OF_ARCHIVE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = unzGoToNextFile(zip);
|
||||||
|
if (result == UNZ_END_OF_LIST_OF_FILE) {
|
||||||
|
state = END_OF_ARCHIVE;
|
||||||
|
break;
|
||||||
|
} else if (result != UNZ_OK) {
|
||||||
|
SG_LOG(SG_IO, SG_ALERT, outer->rootPath() << "failed to go to next file in archive:" << result);
|
||||||
|
state = BAD_ARCHIVE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
unzClose(zip);
|
unzClose(zip);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,11 @@ public:
|
|||||||
Stop
|
Stop
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SGPath rootPath() const
|
||||||
|
{
|
||||||
|
return _rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user