X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fupdate_image.c;h=9453f2e02cf9d23bee7ae83861c18089e9974131;hb=1e167170cdc048c6a93db6d994d9da161f8553d9;hp=7247b1c06b8fb61064974f21c27e0baa670d1964;hpb=12d47b06960d51e4f254ebbc882b05445c992f1d;p=wimlib diff --git a/src/update_image.c b/src/update_image.c index 7247b1c0..9453f2e0 100644 --- a/src/update_image.c +++ b/src/update_image.c @@ -48,6 +48,7 @@ do_overlay(struct wim_dentry *target, struct wim_dentry *branch) } rb_root = &branch->d_inode->i_children; + LIST_HEAD(moved_children); while (rb_root->rb_node) { /* While @branch has children... */ struct wim_dentry *child = rbnode_dentry(rb_root->rb_node); struct wim_dentry *existing; @@ -61,12 +62,17 @@ do_overlay(struct wim_dentry *target, struct wim_dentry *branch) int ret; ret = do_overlay(existing, child); if (ret) { - /* Overlay failed. Revert the change to avoid - * leaking the directory tree rooted at @child. - * */ + /* Overlay failed. Revert the changes. */ dentry_add_child(branch, child); + list_for_each_entry(child, &moved_children, tmp_list) + { + unlink_dentry(child); + dentry_add_child(branch, child); + } return ret; } + } else { + list_add(&child->tmp_list, &moved_children); } } free_dentry(branch); @@ -328,6 +334,14 @@ execute_delete_command(WIMStruct *wim, return 0; } +static int +free_dentry_full_path(struct wim_dentry *dentry, void *_ignore) +{ + FREE(dentry->_full_path); + dentry->_full_path = NULL; + return 0; +} + /* * Rename a file or directory in the WIM. * @@ -388,6 +402,8 @@ rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to) } unlink_dentry(src); dentry_add_child(parent_of_dst, src); + if (src->_full_path) + for_dentry_in_tree(src, free_dentry_full_path, NULL); return 0; }