Fix race condition when inserting parent directory am: 971408ec8d
am: 1d0c36fe92

Change-Id: I0dbdac868a74f52f7cb166d7b23ff5434b8a9360