win: handle moving files in and out of the repo

Summary:
The documentation for PRJ_NOTIFICATION_FILE_RENAMED points out that the
filenames can be empty strings to represent files moved to and from the
repository itself. By not special casing this we were trying to create and/or
remove an empty file at the root of the repo which would lead to an overlay
corruption.

Reviewed By: genevievehelsel

Differential Revision: D21961579

fbshipit-source-id: fbfd872ca0377cb90224eba5505ff406812d51a7
This commit is contained in:
Xavier Deguillard 2020-06-10 11:04:22 -07:00 committed by Facebook GitHub Bot
parent e05de75a3f
commit 4b8809c786

View File

@ -386,16 +386,21 @@ void EdenDispatcher::notification(
case PRJ_NOTIFICATION_FILE_RENAMED: {
auto destFile = wideCharToEdenRelativePath(destinationFileName);
XLOGF(DBG6, "RENAMED {} -> {}", relPath, destFile);
getMount().renameFile(relPath, destFile);
if (!destFile.empty()) {
getMount().renameFile(relPath, destFile);
}
// The Prjfs could create a Tombstones for the original file. If the
// Tombstone will be created or not depends on the origin of the file.
// We do not have that info here, so we try to remove the Tombstone and
// not worry about the failures.
// TODO(puneetk): We could add the file origin information in the
// DirEntry and refer to that before calling removeDeletedFile.
getMount().getFsChannel()->removeDeletedFile(relPath);
if (!relPath.empty()) {
// TODO(puneetk): We could add the file origin information in the
// DirEntry and refer to that before calling removeDeletedFile.
getMount().getFsChannel()->removeDeletedFile(relPath);
}
break;
}