Watch OneDrive folder that is not automatically downloaded
Thanks a lot for this library, I use it for some things in clipboard-sync. But there is another thing which I'd like to use, which is apparently not supported yet (if even possible to):
OneDrive has the Files on demand feature, which allows to keep track of the files but only download them when necessary.
This feature can be enabled or disabled by right clicking the folder and toggling the Always keep on this device option.
I'm testing fswin.dirWatcher to check if it can watch files without having them downloaded first (other file watchers like Chokidar will only fire events for files which are actually downloaded).
But it does not seem to work.
When Always keep on this device is enabled, this the the list of events I can get from fswin.dirWatcher on a file creation:
"1-test.txt~RF1b9046.TMP" is added. it could be created or moved to here.
"1-test.txt~RF1b9046.TMP" is removed. it could be deleted or moved from here.
"1-test.txt" is added. it could be created or moved to here.
"1-test.txt~RF1b9046.TMP" is removed. it could be deleted or moved from here.
"1-test.txt" is modified. this event does not contain any detail of what change is made.
But as soon as I disable Always keep on this device from OneDrive, no more events are fired at all when I create the file from another computer.
It's funny though, because removed events are still being fired even if the file was never downloaded if I delete the file from another computer.
Maybe there is something that can be done to start capturing such events as well?
I can reproduce this issue. But still got no clue on how OneDrive creates a local placeholder file. Perhaps ReadDirectoryChangesW is not suitable for this kind of situation. And to solve the issue, we might need to figure out how does Explorer work first.
Out of curiosity, apparently not even https://github.com/files-community/files is able to detect the new files in such case. I have to manually refresh so that they appear in the list.
These are the attributes for such file (.txt), as captured by fswin.getAttributes()
{
CREATION_TIME: 2023-07-17T15:24:45.435Z,
LAST_ACCESS_TIME: 2023-07-17T15:24:45.435Z,
LAST_WRITE_TIME: 2023-07-17T15:24:49.000Z,
SIZE: 27,
LINK_COUNT: 1,
RAW_ATTRIBUTES: 4199968,
IS_ARCHIVED: true,
IS_COMPRESSED: false,
IS_DEVICE: false,
IS_DIRECTORY: false,
IS_ENCRYPTED: false,
IS_HIDDEN: false,
IS_NOT_CONTENT_INDEXED: false,
IS_OFFLINE: true,
IS_READ_ONLY: false,
IS_SPARSE_FILE: true,
IS_SYSTEM: false,
IS_TEMPORARY: false,
IS_INTEGRITY_STREAM: false,
IS_NO_SCRUB_DATA: false,
IS_RECALL_ON_DATA_ACCESS: true,
IS_RECALL_ON_OPEN: false,
IS_VIRTUAL: false,
IS_EA: false,
IS_PINNED: false,
IS_UNPINNED: false,
IS_REPARSE_POINT: true
}