lib: Hoist unlinkat() cleanup API to fsutil, use in pull
The pull code also could make use of this in both the metadata and content paths. I changed it to own the tempfile malloc (just like `GLnxTmpFile`), since there's no reason to have different lifetimes for the filename and the file, and that way we only have one variable rather than two. The content path turns out to be a special case though, where at least for mirroring archives, we directly pass the file *path* down into `_ostree_repo_commit_loose_final()`. This is prep for `GLnxTmpFile` porting. Closes: #957 Approved by: jlebon
This commit is contained in:
1 parent
1147267e4d
commit
4dee1984dc
3 files changed
+51
-46
No files matched your search
@@ -49,6 +49,34 @@ ot_link_tmpfile_at (OtTmpfile *tmpf,
|
||||
const char *target,
|
||||
GError **error);
|
||||
|
||||
|
||||
/* A little helper to call unlinkat() as a cleanup
|
||||
* function. Mostly only necessary to handle
|
||||
* deletion of temporary symlinks.
|
||||
*/
|
||||
typedef struct {
|
||||
int dfd;
|
||||
char *path;
|
||||
} OtCleanupUnlinkat;
|
||||
|
||||
static inline void
|
||||
ot_cleanup_unlinkat_clear (OtCleanupUnlinkat *cleanup)
|
||||
{
|
||||
g_clear_pointer (&cleanup->path, g_free);
|
||||
}
|
||||
|
||||
static inline void
|
||||
ot_cleanup_unlinkat (OtCleanupUnlinkat *cleanup)
|
||||
{
|
||||
if (cleanup->path)
|
||||
{
|
||||
(void) unlinkat (cleanup->dfd, cleanup->path, 0);
|
||||
ot_cleanup_unlinkat_clear (cleanup);
|
||||
}
|
||||
}
|
||||
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(OtCleanupUnlinkat, ot_cleanup_unlinkat);
|
||||
|
||||
|
||||
GFile * ot_fdrel_to_gfile (int dfd, const char *path);
|
||||
|
||||
gboolean ot_readlinkat_gfile_info (int dfd,
|
||||
|
||||
Reference in new issue
Block a user