Skip to content

MacOS watcher can omit directory create events #62124

@davidmorgan

Description

@davidmorgan

@mraleph Linux+Windows watcher are looking good now, found one more issue to dig into / work around on MacOS, with any luck the last for a while :)

Repro

import 'dart:io';

void main () async {
  final t = Directory.systemTemp.createTempSync();
  t.watch(recursive: true).listen(print);

  Directory('${t.path}/a').createSync();
  File('${t.path}/a/1').createSync();
  Directory('${t.path}/a').renameSync('${t.path}/b');
  File('${t.path}/b/1').writeAsStringSync('_');
  Directory('${t.path}/b').renameSync('${t.path}/c');
  File('${t.path}/c/1').writeAsStringSync('__');
  Directory('${t.path}/c').deleteSync(recursive: true);

  await Future.delayed(Duration(seconds: 1));
}

prints

FileSystemCreateEvent('.../a/1', isDirectory=false)
FileSystemCreateEvent('.../a', isDirectory=true)
FileSystemDeleteEvent('.../a')
FileSystemModifyEvent('.../b/1', isDirectory=false, contentChanged=true)
FileSystemDeleteEvent('.../b')
FileSystemModifyEvent('.../c/1', isDirectory=false, contentChanged=true)
FileSystemDeleteEvent('.../c/1')
FileSystemDeleteEvent('.../c')

which is giving "delete" events for directories without any corresponding "create" event.

watcher needs to figure out that a "delete" event refers to a directory, the create event would have helped :) ... e.g. when "b" is deleted we need to know it's a directory to know that "b/1" is deleted.

Workaround should be to infer the existence of "b" from the existence of "b/1" instead of relying on the directory create event for "b".

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions