From a6d08657aa868a0d5c7b5dd494e16f65415a148f Mon Sep 17 00:00:00 2001
From: Yu Qi Zhang <jzehrarnyg@gmail.com>
Date: Thu, 16 Jun 2016 15:39:32 +0000
Subject: [PATCH] fdio: Delete .tmp file on failure

We noticed the temp files being left over in ostree when (mistakenly)
trying to replace the contents of a subpath that wasn't a directory.

In the future we should look at the systemd code using `O_TMPFILE`
here.
---
 glnx-fdio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/glnx-fdio.c b/glnx-fdio.c
index 62371d028..cdbb69fe1 100644
--- a/glnx-fdio.c
+++ b/glnx-fdio.c
@@ -746,6 +746,8 @@ glnx_file_replace_contents_with_perms_at (int                   dfd,
 
   ret = TRUE;
  out:
+  if (!ret)
+    (void) unlink (tmppath);
   return ret;
 }
 
-- 
GitLab