Browse Source

refactor(neon,neon_files): Refactor platform path getters

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/495/head
jld3103 1 year ago
parent
commit
358d2b5b93
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/neon/neon/lib/src/platform/android.dart
  2. 4
      packages/neon/neon/lib/src/platform/linux.dart
  3. 4
      packages/neon/neon/lib/src/platform/platform.dart
  4. 2
      packages/neon/neon/lib/src/utils/request_manager.dart
  5. 4
      packages/neon/neon_files/lib/blocs/files.dart

4
packages/neon/neon/lib/src/platform/android.dart

@ -29,13 +29,13 @@ class AndroidNeonPlatform implements NeonPlatform {
bool get canUseWindowManager => false; bool get canUseWindowManager => false;
@override @override
Future<String> getApplicationCachePath() async { Future<String> get applicationCachePath async {
final tempDir = await getTemporaryDirectory(); final tempDir = await getTemporaryDirectory();
return tempDir.absolute.path; return tempDir.absolute.path;
} }
@override @override
Future<String> getUserAccessibleAppDataPath() async { Future<String> get userAccessibleAppDataPath async {
if (!await Permission.storage.request().isGranted) { if (!await Permission.storage.request().isGranted) {
throw MissingPermissionException(Permission.storage); throw MissingPermissionException(Permission.storage);
} }

4
packages/neon/neon/lib/src/platform/linux.dart

@ -30,13 +30,13 @@ class LinuxNeonPlatform implements NeonPlatform {
bool get canUsePushNotifications => false; bool get canUsePushNotifications => false;
@override @override
String getApplicationCachePath() => p.join( String get applicationCachePath => p.join(
xdg.cacheHome.absolute.path, xdg.cacheHome.absolute.path,
'de.provokateurin.neon', 'de.provokateurin.neon',
); );
@override @override
String getUserAccessibleAppDataPath() => p.join(Platform.environment['HOME']!, 'Neon'); String get userAccessibleAppDataPath => p.join(Platform.environment['HOME']!, 'Neon');
@override @override
void init() { void init() {

4
packages/neon/neon/lib/src/platform/platform.dart

@ -53,9 +53,9 @@ abstract interface class NeonPlatform {
abstract final bool canUsePushNotifications; abstract final bool canUsePushNotifications;
FutureOr<String> getApplicationCachePath(); FutureOr<String> get applicationCachePath;
FutureOr<String> getUserAccessibleAppDataPath(); FutureOr<String> get userAccessibleAppDataPath;
FutureOr init(); FutureOr init();
} }

2
packages/neon/neon/lib/src/utils/request_manager.dart

@ -196,7 +196,7 @@ class Cache {
_database = await openDatabase( _database = await openDatabase(
p.join( p.join(
await NeonPlatform.instance.getApplicationCachePath(), await NeonPlatform.instance.applicationCachePath,
'cache.db', 'cache.db',
), ),
version: 1, version: 1,

4
packages/neon/neon_files/lib/blocs/files.dart

@ -84,7 +84,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
() async { () async {
final file = File( final file = File(
p.join( p.join(
await NeonPlatform.instance.getApplicationCachePath(), await NeonPlatform.instance.applicationCachePath,
'files', 'files',
etag.replaceAll('"', ''), etag.replaceAll('"', ''),
path.last, path.last,
@ -137,7 +137,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
() async { () async {
final file = File( final file = File(
p.join( p.join(
await NeonPlatform.instance.getUserAccessibleAppDataPath(), await NeonPlatform.instance.userAccessibleAppDataPath,
account.humanReadableID, account.humanReadableID,
'files', 'files',
path.join(Platform.pathSeparator), path.join(Platform.pathSeparator),

Loading…
Cancel
Save