This commit is contained in:
Hanh 2022-11-22 23:17:25 +08:00
parent ce0a077f68
commit f2aa2ec392
6 changed files with 30 additions and 14 deletions

View File

@ -19,4 +19,7 @@ RUN cargo install cargo-make
RUN curl -o flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.3.8-stable.tar.xz RUN curl -o flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.3.8-stable.tar.xz
RUN tar xvf flutter.tar.xz RUN tar xvf flutter.tar.xz
RUN rm -f flutter.tar.xz RUN rm -f flutter.tar.xz
RUN mkdir /root/.zcash-params
RUN curl -o /root/.zcash-params/sapling-spend.params https://download.z.cash/downloads/sapling-spend.params
RUN curl -o /root/.zcash-params/sapling-output.params https://download.z.cash/downloads/sapling-output.params

View File

@ -49,8 +49,7 @@ abstract class CoinBase {
Future<bool> tryImport(PlatformFile file) async { Future<bool> tryImport(PlatformFile file) async {
if (file.name == dbName) { if (file.name == dbName) {
Directory tempDir = await getTemporaryDirectory(); final dest = p.join(settings.tempDir, dbName);
final dest = p.join(tempDir.path, dbName);
await File(file.path!).copy(dest); // save to temporary directory await File(file.path!).copy(dest); // save to temporary directory
return true; return true;
} }
@ -58,8 +57,7 @@ abstract class CoinBase {
} }
Future<void> importFromTemp() async { Future<void> importFromTemp() async {
Directory tempDir = await getTemporaryDirectory(); final src = File(p.join(settings.tempDir, dbName));
final src = File(p.join(tempDir.path, dbName));
print("Import from ${src.path}"); print("Import from ${src.path}");
if (await src.exists()) { if (await src.exists()) {
print("copied to ${dbFullPath}"); print("copied to ${dbFullPath}");

View File

@ -5,6 +5,7 @@ import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'dart:ui'; import 'dart:ui';
import 'package:path/path.dart' as p;
import 'package:csv/csv.dart'; import 'package:csv/csv.dart';
import 'package:currency_text_input_formatter/currency_text_input_formatter.dart'; import 'package:currency_text_input_formatter/currency_text_input_formatter.dart';
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
@ -817,8 +818,8 @@ Future<void> saveFile(String data, String filename, String title) async {
if (isMobile()) { if (isMobile()) {
final context = navigatorKey.currentContext!; final context = navigatorKey.currentContext!;
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
Directory tempDir = await getTemporaryDirectory(); final tempDir = settings.tempDir;
String fn = "${tempDir.path}/$filename"; String fn = p.join(tempDir, filename);
final file = File(fn); final file = File(fn);
await file.writeAsString(data); await file.writeAsString(data);
return Share.shareFiles([fn], subject: title, sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2)); return Share.shareFiles([fn], subject: title, sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));
@ -850,8 +851,7 @@ Future<void> exportFile(BuildContext context, String path, String title) async {
} }
Future<File> getRecoveryFile() async { Future<File> getRecoveryFile() async {
Directory tempDir = await getTemporaryDirectory(); String fn = p.join(settings.tempDir, RECOVERY_FILE);
String fn = "${tempDir.path}/$RECOVERY_FILE";
final f = File(fn); final f = File(fn);
return f; return f;
} }
@ -921,13 +921,29 @@ DynamicLibrary _openOnLinux() {
} }
} }
Future<String> getDbPath() async { Future<String> getDataPath() async {
if (isMobile()) return await getDatabasesPath();
String? home; String? home;
if (Platform.isWindows) home = Platform.environment['LOCALAPPDATA']; if (Platform.isWindows) home = Platform.environment['LOCALAPPDATA'];
if (Platform.isLinux) home = Platform.environment['XDG_DATA_HOME']; if (Platform.isLinux) home = Platform.environment['XDG_DATA_HOME'];
if (Platform.isMacOS) home = Platform.environment['HOME']; if (Platform.isMacOS) home = Platform.environment['HOME'];
final h = home ?? ""; final h = home ?? "";
return h;
}
Future<String> getTempPath() async {
if (isMobile()) {
final d = await getTemporaryDirectory();
return d.path;
}
final dataPath = await getDataPath();
final tempPath = p.join(dataPath, "tmp");
Directory(tempPath).createSync(recursive: true);
return tempPath;
}
Future<String> getDbPath() async {
if (isMobile()) return await getDatabasesPath();
final h = await getDataPath();
return "$h/databases"; return "$h/databases";
} }

View File

@ -213,8 +213,7 @@ abstract class _Settings with Store {
@action @action
Future<bool> restore() async { Future<bool> restore() async {
final tempDirectory = await getTemporaryDirectory(); tempDir = await getTempPath();
tempDir = tempDirectory.path;
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
version = prefs.getString('version') ?? "1.0.0"; version = prefs.getString('version') ?? "1.0.0";
simpleMode = prefs.getBool('simple_mode') ?? true; simpleMode = prefs.getBool('simple_mode') ?? true;

View File

@ -21,6 +21,6 @@
<content_rating type="oars-1.1"/> <content_rating type="oars-1.1"/>
<developer_name>Hanh Huynh Huu</developer_name> <developer_name>Hanh Huynh Huu</developer_name>
<releases> <releases>
<release version="1.2.14+287" date="2022-09-28" /> <release version="1.2.16+301" date="2022-11-22" />
</releases> </releases>
</component> </component>

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.2.16+300 version: 1.2.16+301
environment: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"