Add better checking and error messages.
This commit is contained in:
@@ -43,6 +43,9 @@ mError(Processor::DefaultError), mInstalling(i)
|
|||||||
|
|
||||||
if (mInstalling)
|
if (mInstalling)
|
||||||
{
|
{
|
||||||
|
if (!DoesFileExist(path))
|
||||||
|
throw CString("Archive file not present.");
|
||||||
|
|
||||||
char archivePath[] = "/tmp/installerXXXXXX.tar";
|
char archivePath[] = "/tmp/installerXXXXXX.tar";
|
||||||
int fd = mkstemps(archivePath, 4);
|
int fd = mkstemps(archivePath, 4);
|
||||||
|
|
||||||
@@ -53,11 +56,15 @@ mError(Processor::DefaultError), mInstalling(i)
|
|||||||
|
|
||||||
char toolPath[] = "/usr/bin/gunzip";
|
char toolPath[] = "/usr/bin/gunzip";
|
||||||
|
|
||||||
|
try {
|
||||||
if(CallTool2(true, -1, fd, -1, toolPath, "-c", path.c_str(), NULL))
|
if(CallTool2(true, -1, fd, -1, toolPath, "-c", path.c_str(), NULL))
|
||||||
{
|
throw CString("Archive file not handled correctly.");
|
||||||
|
} catch (CString& e) {
|
||||||
|
close(fd);
|
||||||
unlink(mPath);
|
unlink(mPath);
|
||||||
throw CString("Archive file not handled correctly or not present.");
|
throw;
|
||||||
}
|
}
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mPath = path;
|
mPath = path;
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ err:
|
|||||||
|
|
||||||
int CallTool3(bool blocking, int fd_in, int fd_out, int fd_err, const char *path, char *const *arguments)
|
int CallTool3(bool blocking, int fd_in, int fd_out, int fd_err, const char *path, char *const *arguments)
|
||||||
{
|
{
|
||||||
|
if (!DoesFileExist(path))
|
||||||
|
throw CString("The tool \"") + path + "\" does not exist.";
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
|
|
||||||
switch (pid)
|
switch (pid)
|
||||||
|
|||||||
Reference in New Issue
Block a user