diff --git a/lib/api/wsl.dart b/lib/api/wsl.dart index 973ab25..26252e1 100644 --- a/lib/api/wsl.dart +++ b/lib/api/wsl.dart @@ -263,13 +263,15 @@ class WSLApi { // Check if folder is empty and delete String path = getInstancePath(distribution).path; - Directory dir = Directory(path); - if (dir.existsSync()) { - if (dir.listSync().isEmpty) { - dir.deleteSync(); + // Wait 10 seconds in async then delete for Windows to release file + Future.delayed(const Duration(seconds: 10), () { + Directory dir = Directory(path); + if (dir.existsSync()) { + if (dir.listSync().isEmpty) { + dir.deleteSync(recursive: true); + } } - } - + }); return results.stdout; } diff --git a/test/wsl_test.dart b/test/wsl_test.dart index 8bec9a2..bf0e0bb 100644 --- a/test/wsl_test.dart +++ b/test/wsl_test.dart @@ -126,6 +126,9 @@ void main() { await WSLApi().remove('test'); expect(await isInstance('test'), false); + // Check if folder is deleted + expect(await Directory('C:/WSL2-Distros/test').exists(), false); + // Test without download // Test creating it await createDistro(