| 789 | // Finishes off the renaming process by adding the file to the new |
| 790 | // parent. |
| 791 | const completeRename = () => { |
| 792 | newParentList[newName] = fileId; |
| 793 | // Commit old parent's list. |
| 794 | tx.put(oldParentINode.id, Buffer.from(JSON.stringify(oldParentList)), true, (e: ApiError) => { |
| 795 | if (noErrorTx(e, tx, cb)) { |
| 796 | if (oldParent === newParent) { |
| 797 | // DONE! |
| 798 | tx.commit(cb); |
| 799 | } else { |
| 800 | // Commit new parent's list. |
| 801 | tx.put(newParentINode.id, Buffer.from(JSON.stringify(newParentList)), true, (e: ApiError) => { |
| 802 | if (noErrorTx(e, tx, cb)) { |
| 803 | tx.commit(cb); |
| 804 | } |
| 805 | }); |
| 806 | } |
| 807 | } |
| 808 | }); |
| 809 | }; |
| 810 | |
| 811 | if (newParentList[newName]) { |
| 812 | // 'newPath' already exists. Check if it's a file or a directory, and |