]> wimlib.net Git - wimlib/commitdiff
rename_wim_path(): Fix journaling of name change
authorEric Biggers <ebiggers3@gmail.com>
Mon, 28 Apr 2014 05:51:10 +0000 (00:51 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 28 Apr 2014 05:51:10 +0000 (00:51 -0500)
src/update_image.c

index 3e7613fcfa5dbc12e37a7bdd3985a1cc24b764cb..06a6ad30261434a3a6a0107602b29831bb2b07ef 100644 (file)
@@ -1022,28 +1022,23 @@ rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to,
                return -EBUSY;
 
        if (j) {
+               if (dst)
+                       if (journaled_unlink(j, dst))
+                               return -ENOMEM;
+               if (journaled_unlink(j, src))
+                       return -ENOMEM;
                if (journaled_change_name(j, src, path_basename(to)))
                        return -ENOMEM;
+               if (journaled_link(j, src, parent_of_dst))
+                       return -ENOMEM;
        } else {
                ret = dentry_set_name(src, path_basename(to));
                if (ret)
                        return -ENOMEM;
-       }
-       if (dst) {
-               if (j) {
-                       if (journaled_unlink(j, dst))
-                               return -ENOMEM;
-               } else {
+               if (dst) {
                        unlink_dentry(dst);
                        free_dentry_tree(dst, wim->lookup_table);
                }
-       }
-       if (j) {
-               if (journaled_unlink(j, src))
-                       return -ENOMEM;
-               if (journaled_link(j, src, parent_of_dst))
-                       return -ENOMEM;
-       } else {
                unlink_dentry(src);
                dentry_add_child(parent_of_dst, src);
        }