Skip to content

macOS/Windows: rename handling seems wrong? #150

Description

@bpasero

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions