Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cleanup path and cleanup text #207

Merged
merged 11 commits into from
Aug 13, 2023
Merged
20 changes: 11 additions & 9 deletions lib/api/wsl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -546,14 +548,14 @@ class WSLApi {

/// Clean up WSL distros. Exporting, deleting, and importing.
Future<String> cleanup(String distribution) async {
var file = getInstancePath(distribution).file('export.tar.gz');
var instancePath = getInstancePath(distribution);
var file = instancePath.file('export.tar.gz');

// Export, remove, and import
await export(distribution, file);
await remove(distribution);
var res = await import(distribution, '', file);

return res;
return await import(distribution, instancePath.path, file);
}

/// Returns list of WSL distros
Expand Down
8 changes: 4 additions & 4 deletions lib/dialogs/info_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ class ClickableDependency extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
Button(
onPressed: () =>
launchUrl(Uri.parse("https://pub.dev/packages/$name")),
child: Text(name)),
TextButton(
Button(
onPressed: () => launchUrl(
Uri.parse("https://pub.dev/packages/$name/license")),
child: const Text("(LICENSE)")),
Expand All @@ -178,7 +178,7 @@ class ClickableUrl extends StatelessWidget {
Widget build(BuildContext context) {
return MouseRegion(
cursor: SystemMouseCursors.click,
child: TextButton(
child: Button(
onPressed: () async {
plausible.event(name: clickEvent);
launchUrl(Uri.parse(url));
Expand All @@ -204,7 +204,7 @@ class ClickableText extends StatelessWidget {
Widget build(BuildContext context) {
return MouseRegion(
cursor: SystemMouseCursors.click,
child: TextButton(onPressed: onPressed, child: Text(text)),
child: Button(onPressed: onPressed, child: Text(text)),
);
}
}
2 changes: 1 addition & 1 deletion lib/dialogs/install_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InstallDialog extends StatelessWidget {
color: const Color.fromRGBO(0, 0, 0, 0.2),
child: Padding(
padding: const EdgeInsets.only(left: 4.0, right: 4.0),
child: TextButton(
child: Button(
onPressed: () {
plausible.event(name: "wsl_install");
WSLApi().installWSL();
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"language-text": "Language",
"languagechange-text": "Language change will take effect after restart.",
"notemplates-text": "No templates found",
"cleanuptitle-text": "Clean up WSL instance ($s0)",
"cleanuptitle-text": "Clean up WSL instance (%s0)",
"cleanupbody-text": "Do you really want to clean up the distribution? This will export and re-import the distribution. This may take some time.",
"continue-text": "Continue",
"cleanup-text": "Cleanup",
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"language-text": "Idioma",
"languagechange-text": "A alteração de idioma terá efeito após o reinício.",
"notemplates-text": "Nenhum modelo encontrado",
"cleanuptitle-text": "Limpar instância WSL ($s0)",
"cleanuptitle-text": "Limpar instância WSL (%s0)",
"cleanupbody-text": "Você realmente quer limpar a distribuição? Isso exportará e importará a distribuição novamente. Isso pode levar algum tempo.",
"continue-text": "Continuar",
"cleanuptext-text": "Limpar",
Expand Down
10 changes: 5 additions & 5 deletions lib/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"startdirectorypath-text": "起始目录路径",
"wsldefaultuser-text": "(可选)要使用的 WSL 默认用户",
"emptyfieldsfordefault-text": "(如果您的 WSL 版本不支持,请清空默认字段)",
"runquickaction-text": "运行片段",
"runquickaction-text": "运行代码片段",
"upload-text": "上传",
"startstopserving-text": "开始/停止在网络上提供服务",
"startedserving-text": "正在网络上为 %s 提供服务",
Expand All @@ -90,15 +90,15 @@
"yesoverride-text": "是的,同步(覆盖)",
"settingname-text": "设置名称",
"yourcodehere-text": "填入你的代码",
"addquickaction-text": "添加片段",
"addquickactioninfo-text": "添加片段,您将在此处看到它。",
"addquickaction-text": "添加代码片段",
"addquickactioninfo-text": "添加代码片段,您将在此处看到它。",
"newversion-text": "有新版本可用",
"downloadnow-text": "现在下载",
"orcheck-text": "或检查",
"windowsstore-text": "Windows 商店",
"homepage-text": "主界面",
"about-text": "关于此软件",
"managequickactions-text": "管理片段",
"managequickactions-text": "管理代码片段",
"addinstance-text": "添加实例",
"editwslconfig-text": "直接编辑 .wslconfig",
"stopwsl-text": "停止 WSL",
Expand All @@ -124,7 +124,7 @@
"addcommunityactions-text": "添加社区快速操作",
"done-text": "完成",
"search-text": "搜索",
"shareyourquickaction-text": "分享你的片段",
"shareyourquickaction-text": "分享你的代码片段",
"wslsettings-text": "WSL 设置",
"boot-text": "启动",
"automount-text": "自动挂载",
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"language-text": "語言",
"languagechange-text": "語言變更將在重新啟動後生效。",
"notemplates-text": "沒有找到範本",
"cleanuptitle-text": "清理 WSL 安裝實體 ($s0)",
"cleanuptitle-text": "清理 WSL 安裝實體 (%s0)",
"cleanupbody-text": "您確定要清理發行版本嗎?這將匯出並重新匯入發行版本。這可能需要一些時間。",
"continue-text": "繼續",
"cleanup-text": "清理",
Expand Down
12 changes: 5 additions & 7 deletions lib/nav/init.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:dio/dio.dart';
import 'package:fluent_ui/fluent_ui.dart' hide Page;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:localization/localization.dart';
import 'package:system_theme/system_theme.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:wsl2distromanager/api/app.dart';
import 'package:wsl2distromanager/components/constants.dart';
Expand Down Expand Up @@ -45,9 +43,9 @@ initRoot(statusMsg) async {
// if (kDebugMode) {
// prefs.remove('version');
// }
if (kDebugMode) {
prefs.setString('version', '1.8.0');
}
// if (kDebugMode) {
// prefs.setString('version', '1.8.0');
// }

// Check updates
App app = App();
Expand Down Expand Up @@ -104,9 +102,9 @@ initRoot(statusMsg) async {
// }

// Get system dark mode
if (SystemTheme.isDarkMode) {
if (ThemeMode.system == ThemeMode.dark) {
AppTheme().mode = ThemeMode.dark;
} else {
} else if (ThemeMode.system == ThemeMode.light) {
AppTheme().mode = ThemeMode.light;
}
}
Loading