Skip to content

Commit

Permalink
Ignore errors on listing
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Aug 28, 2024
1 parent d9fecad commit 48a3bac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/lw_file_system/lib/src/api/base/directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ mixin GeneralDirectoryFileSystem<T> on GeneralFileSystem {
_findAvailableName(path, hasAsset);

Future<FileSystemFile<T>> createFileWithName(T data,
{String? name, String? fileExtension, String? directory}) {
{String? name, String? suffix, String? directory}) {
final path = convertNameToFile(
name: name,
fileExtension: fileExtension,
suffix: suffix,
directory: directory,
);
return createFile(path, data);
Expand Down
6 changes: 3 additions & 3 deletions packages/lw_file_system/lib/src/api/base/key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ mixin GeneralKeyFileSystem<T> on GeneralFileSystem {
_findAvailableName(path, hasKey);

Future<String> createFileWithName(T data,
{String? name, String? fileExtension, String? directory}) {
{String? name, String? suffix, String? directory}) {
final path = convertNameToFile(
name: name,
fileExtension: fileExtension,
suffix: suffix,
directory: directory,
);
return createFile(path, data);
Expand Down Expand Up @@ -46,7 +46,7 @@ mixin GeneralKeyFileSystem<T> on GeneralFileSystem {
Stream<List<FileSystemFile<T>>> fetchFiles() async* {
final files = <FileSystemFile<T>>[];
yield files;
await for (final file in listFiles()) {
await for (final file in listFiles().handleError((_, __) {})) {
files.add(file);
yield files;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/lw_file_system/lib/src/api/file_system_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ abstract class GeneralFileSystem {

String normalizePath(String path) => _pathContext.canonicalize(path);

String convertNameToFile(
{String? name, String? fileExtension, String? directory}) {
String convertNameToFile({String? name, String? suffix, String? directory}) {
name ??= '';
fileExtension ??= '';
suffix ??= '';
directory ??= '';
if (name.isEmpty) {
name = config.getUnnamed();
}
name = name.replaceAll(RegExp(r'[\\/:\*\?"<>\|\n\0-\x1F\x7F-\xFF]'), '_');
return p.join(directory, '$name$fileExtension');
return p.join(directory, '$name$suffix');
}

Future<String> _findAvailableName(
Expand Down
2 changes: 1 addition & 1 deletion packages/lw_file_system/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
git:
url: https://github.com/LinwoodDev/dart_pkgs
path: packages/lw_file_system_api
ref: dfda6c2e3cef2e29511f97e9470fd4deb8e0c573
ref: d9fecade26792a9f79996d373a7ce269b2419fe1
# path: ^1.8.0

dev_dependencies:
Expand Down

0 comments on commit 48a3bac

Please sign in to comment.