Fixed empty folders when deleting (#206)
* Changed "Quick actions" to "snippets" * Changed Community Actions to Snippets * Version bump * Version bump * Changed snippet to code snippet * Upgraded dependencies * Fixed windows recreating distro folders
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user