curlget: remove leftover files
@@ -518,7 +518,10 @@ static int moveFile(const char *source, const char *dest)
{
return -1;
}
- unlink(source);
+ if(unlink(source))
+ {
+ return -1;
+ }
return 0;
}
@@ -892,7 +895,13 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA
{
if (data->useLocalCopy)
{
- moveFile (data->tmpFile, data->path);
+ if(moveFile (tmpFile, data->path))
+ {
+ if(data->tmpFile)
+ {
+ unlink(data->tmpFile);
+ }
+ }
data->tmpFile = NULL;
keySetString (parentKey, data->path);
}
@@ -909,6 +918,10 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA
elektraFree (data->path);
data->path = NULL;
}
+ if (tmpFile)
+ {
+ unlink(tmpFile);
+ }
}
}
else
@@ -926,9 +939,15 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA
elektraFree (data->path);
data->path = NULL;
}
+ if (tmpFile)
+ {
+ unlink(tmpFile);
+ }
}
else
{
+ if(tmpFile)
+ unlink(tmpFile);
if (data->tmpFile)
{
unlink (data->tmpFile);
