sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Directory.deleteSync(recursive: true) failing if directory is not empty

Open tvolkert opened this issue 6 years ago • 2 comments

Observed on the following Dart version:

$ dart --version
Dart VM version: 2.5.0-dev.3.0.flutter-35382f9b14 (Wed Aug 28 18:50:51 2019 +0000) on "macos_x64"
  FileSystemException: Deletion failed, path = '/private/var/folders/dy/cv4xnlnn7sb_4bz47wvmdwjw003g3j/T/file_test_JGEQQ7' (OS Error: Directory not empty, errno = 66)
  dart:io                      FileSystemEntity.deleteSync
  test/chroot_test.dart 45:13  main.<fn>.<fn>.<fn>

The test in question has the following setUp() and tearDown() methods - the exception was thrown in tearDown();

io.Directory tmp;

setUp(() {
  tmp = io.Directory.systemTemp.createTempSync('file_test_');
  tmp = io.Directory(tmp.resolveSymbolicLinksSync());
});

tearDown(() {
  tmp.deleteSync(recursive: true);
});

This failure is intermittent - not 100% reproducible.

tvolkert avatar Aug 30 '19 20:08 tvolkert

Prior art:

  • https://github.com/dart-lang/sdk/issues/16264
  • https://github.com/dart-lang/sdk/issues/1757

Except both those are closed, and I just saw this happen today against BE Dart.

tvolkert avatar Aug 30 '19 20:08 tvolkert

I can confirm. And I'm surprised how noone came across this yet.

I think this affects this aswell: https://github.com/flutter/flutter/issues/64410

Thankyou!

alexmercerind avatar Jul 13 '22 10:07 alexmercerind

This is an issue I am seeing as well, it is intermittent.

TMcClain5 avatar Jan 13 '23 14:01 TMcClain5