mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-05 16:15:43 +00:00
Merge remote-tracking branch 'origin/main' into codex/async-ffi-worker-callbacks
This commit is contained in:
commit
f7be97667f
4 files changed
+40
-4
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 391 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 357 KiB |
@@ -19,14 +19,15 @@ String logsDir() {
|
||||
return path.join(Util.getStorageDir(), 'logs');
|
||||
}
|
||||
|
||||
Directory ensureLogDirectory(String logDirPath) {
|
||||
return Directory(logDirPath)..createSync(recursive: true);
|
||||
}
|
||||
|
||||
LogOutput? _buildOutput() {
|
||||
// if is debug mode, don't log to file
|
||||
if (!kDebugMode && Util.isDesktop()) {
|
||||
final logDirPath = logsDir();
|
||||
var logDir = Directory(logsDir());
|
||||
if (!logDir.existsSync()) {
|
||||
logDir.createSync();
|
||||
}
|
||||
ensureLogDirectory(logDirPath);
|
||||
return FileOutput(file: File('$logDirPath/client.log'));
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gopeed/util/log_util.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
void main() {
|
||||
late Directory temporaryDirectory;
|
||||
|
||||
setUp(() async {
|
||||
temporaryDirectory = await Directory.systemTemp.createTemp('gopeed-log-util-');
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await temporaryDirectory.delete(recursive: true);
|
||||
});
|
||||
|
||||
test('creates the log directory when its parents do not exist', () {
|
||||
final logDirPath = path.join(temporaryDirectory.path, 'storage', 'logs');
|
||||
|
||||
final logDirectory = ensureLogDirectory(logDirPath);
|
||||
|
||||
expect(logDirectory.path, logDirPath);
|
||||
expect(logDirectory.existsSync(), isTrue);
|
||||
});
|
||||
|
||||
test('allows the log directory to be initialized repeatedly', () {
|
||||
final logDirPath = path.join(temporaryDirectory.path, 'storage', 'logs');
|
||||
|
||||
ensureLogDirectory(logDirPath);
|
||||
final logDirectory = ensureLogDirectory(logDirPath);
|
||||
|
||||
expect(logDirectory.existsSync(), isTrue);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user