Skip to content

Commit

Permalink
fix lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagocarvalhodev committed Oct 4, 2023
1 parent daef5c6 commit 7bd6e71
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 115 deletions.
10 changes: 5 additions & 5 deletions lib/src/cache_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class IOCacheStorage {

debugPrint('saving file on local storage');

final _file = File('${cacheDir.path}/${entity.name}');
final file = File('${cacheDir.path}/${entity.name}');

final readStream = File(entity.path).openRead();

final writeStream = await _file.open(mode: FileMode.write);
final writeStream = await file.open(mode: FileMode.write);

await for (List<int> chunk in readStream) {
await writeStream.writeFrom(chunk);
}

await writeStream.close();

return _file.path;
return file.path;
}

Future<IOFile> getFileFromStorage(String fileName) async {
Expand All @@ -32,9 +32,9 @@ class IOCacheStorage {

final cacheDir = await _getCacheDir();

final _file = File('${cacheDir.path}/$fileName');
final file = File('${cacheDir.path}/$fileName');

return adapter.fromFile(_file);
return adapter.fromFile(file);
}

Future<void> freeLocalStorage() async {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/utils/path_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Future<String> getDefaultMobileDownloadDir() async {
Future<String> getDefaultAppDir() {
return path_provider
.getApplicationDocumentsDirectory()
.then((value) => value.path + '/');
.then((value) => '${value.path}/');
}

/// Returns the file extension from the file `name`, when having, in other case the extension
Expand Down Expand Up @@ -90,7 +90,7 @@ String getFileExtension({

Future<String> _getDefaultIOSDir() async {
final iosDirectory = await path_provider.getApplicationDocumentsDirectory();
final iosDownloadsDirectory = Directory(iosDirectory.path + '/Downloads/');
final iosDownloadsDirectory = Directory('${iosDirectory.path}/Downloads/');

if (!iosDownloadsDirectory.existsSync()) {
iosDownloadsDirectory.createSync();
Expand Down
8 changes: 4 additions & 4 deletions lib/src/web/web_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ class WebFileSystemProvider implements MultiFileProvider {
class FolderPicker {
Future<void> pickFolderFiles(
Function(Stream<List<IOFile>> stream) getFiles) async {
StreamController<List<IOFile>> _folderController =
StreamController<List<IOFile>> folderController =
StreamController<List<IOFile>>();

/// Set the stream to get the files
getFiles(_folderController.stream);
getFiles(folderController.stream);

final folderInput = FileUploadInputElement();

Expand All @@ -167,10 +167,10 @@ class FolderPicker {

/// To avoid the `IOFileAdapter` imports dart:html, this file will be mounted
/// here.
_folderController.add(files.map((e) => _mountFile(e)).toList());
folderController.add(files.map((e) => _mountFile(e)).toList());

/// Closes to finish the stream with all files
_folderController.close();
folderController.close();
folderInput.removeAttribute('webkitdirectory');
folderInput.remove();
});
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies:
ref: fix-extension
device_info_plus: ^9.0.3
async: ^2.9.0
path: ^1.8.3
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
104 changes: 0 additions & 104 deletions test/src/io_folder_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:ardrive_io/ardrive_io.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down Expand Up @@ -83,107 +81,5 @@ void main() {
expect(files2stLevel.length, 2);
expect(folders2stLevel.isEmpty, true);
});

test(
'fromFileSystemDirectory method should return the folder hierachy correctly',
() async {
// TODO: implement test
// ignore: unused_local_variable
final files = [
_TestFile('first-level/file.xpto'),
_TestFile('first-level/subdirectory-level/subdirectory-file'),
_TestFile('first-level/subdirectory-level/subdirectory-file-1.xpto'),
_TestFile('first-level/subdirectory-level/subdirectory-file-2.xpto'),
_TestFile(
'first-level/subdirectory-level/subdirectory-level2/subdirectory-file-3.xpto'),
];

// await sut.fromFileSystemDirectory(firstLevelDirectory);

// final firstLevelContent = await firstLevelFolder.listContent();

// expect(firstLevelFolder.name, 'first-level');
// expect(firstLevelFolder.path, 'first-level');
// expect(firstLevelFolder.lastModifiedDate,
// firstLevelDirectory.statSync().modified);

// /// First level folder content
// /// first-level/
// /// first-level-file.xpto
// /// subdirectory-level/
// expect(firstLevelContent.whereType<IOFolder>().length, 1);
// expect(firstLevelContent.whereType<IOFile>().length, 1);

// /// subdirectory-level/
// /// subdirectory-file
// /// subdirectory-file-1.xpto
// final secondLevelFolder = firstLevelContent.whereType<IOFolder>().first;
// expect(secondLevelFolder.name, 'subdirectory-level');
// expect(secondLevelFolder.path, secondLevelDirectory.path);
// expect(secondLevelFolder.lastModifiedDate,
// secondLevelDirectory.statSync().modified);

// /// get the second level and verify its content
// final secondLevelContent = await secondLevelFolder.listContent();
// expect(secondLevelContent.whereType<IOFile>().length, 2);
// expect(secondLevelContent.whereType<IOFolder>().length, 0);

// /// Test if `listFiles()` and `listSubfolders()` were mounted correctly
// final files1stLevel = await firstLevelFolder.listFiles();
// final folders1stLevel = await firstLevelFolder.listSubfolders();
// final files2stLevel = await secondLevelFolder.listFiles();
// final folders2stLevel = await secondLevelFolder.listSubfolders();

// /// See the folder structure
// expect(files1stLevel.length, 3);
// expect(folders1stLevel.length, 1);
// expect(files2stLevel.length, 2);
// expect(folders2stLevel.isEmpty, true);
});
});
}

class _TestFile extends MutableIOFilePath {
_TestFile(this.virtualPath);

@override
String virtualPath = '';

@override
// TODO: implement contentType
String get contentType => throw UnimplementedError();

@override
// TODO: implement lastModifiedDate
DateTime get lastModifiedDate => throw UnimplementedError();

@override
// TODO: implement length
FutureOr<int> get length => throw UnimplementedError();

@override
// TODO: implement name
String get name => throw UnimplementedError();

@override
Stream<Uint8List> openReadStream([int start = 0, int? end]) {
// TODO: implement openReadStream
throw UnimplementedError();
}

@override
// TODO: implement path
String get path => throw UnimplementedError();

@override
Future<Uint8List> readAsBytes() {
// TODO: implement readAsBytes
throw UnimplementedError();
}

@override
Future<String> readAsString() {
// TODO: implement readAsString
throw UnimplementedError();
}
}

0 comments on commit 7bd6e71

Please sign in to comment.