Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS/Windows: rename handling seems wrong? #150

Open
bpasero opened this issue Sep 27, 2021 · 0 comments
Open

macOS/Windows: rename handling seems wrong? #150

bpasero opened this issue Sep 27, 2021 · 0 comments

Comments

@bpasero
Copy link

bpasero commented Sep 27, 2021

Looking at the code for how renames are handled on macOS and Windows, I wonder if there are types:

Windows

nsfw/src/win32/Watcher.cpp

Lines 205 to 211 in e8a6e95

mQueue->enqueue(
RENAMED,
getUTF8Directory(fileName),
getUTF8FileName(fileName),
getUTF8Directory(fileName),
getUTF8FileName(fileNameNew)
);

I think it needs to be:

mQueue->enqueue(
  RENAMED,
  getUTF8Directory(fileName),
  getUTF8FileName(fileName),
  getUTF8Directory(fileNameNew),
  getUTF8FileName(fileNameNew)
);

macOS

if (binIterator->second->size() == 2) {
std::string sideA = (*binIterator->second)[0],
sideB = (*binIterator->second)[1];
std::string fullSideA = binIterator->first + "/" + sideA,
fullSideB = binIterator->first + "/" + sideB;
struct stat renameSideA, renameSideB;
bool sideAExists = stat(fullSideA.c_str(), &renameSideA) == 0,
sideBExists = stat(fullSideB.c_str(), &renameSideB) == 0;
if (sideAExists && !sideBExists) {
mQueue->enqueue(RENAMED, binIterator->first, sideB, binIterator->first, sideA);
} else if (!sideAExists && sideBExists) {
mQueue->enqueue(RENAMED, binIterator->first, sideA, binIterator->first, sideB);
} else {
demangle(fullSideA);
demangle(fullSideB);
}

It seems to me that the directory name is the same for both files, but maybe on macOS this kind of event is only fired for a rename of a file in the same folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant