mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
fix: Sync basename parsing for different hosts (#583)
This commit is contained in:
parent
2f7328c954
commit
52c12e63b6
2 changed files with 11 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fladder/util/string_extensions.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart' hide ConnectionState;
|
import 'package:flutter/material.dart' hide ConnectionState;
|
||||||
|
|
||||||
|
|
@ -624,7 +625,7 @@ extension SyncNotifierHelpers on SyncNotifier {
|
||||||
return syncItem.copyWith(
|
return syncItem.copyWith(
|
||||||
fileSize: response.mediaSources?.firstOrNull?.size ?? 0,
|
fileSize: response.mediaSources?.firstOrNull?.size ?? 0,
|
||||||
syncing: false,
|
syncing: false,
|
||||||
videoFileName: response.path?.split('/').lastOrNull ?? "",
|
videoFileName: response.path?.universalBasename ?? "",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:fladder/models/items/item_shared_models.dart';
|
import 'package:fladder/models/items/item_shared_models.dart';
|
||||||
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
extension StringExtensions on String {
|
extension StringExtensions on String {
|
||||||
String capitalize() {
|
String capitalize() {
|
||||||
|
|
@ -49,6 +50,13 @@ extension StringExtensions on String {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Supports both Linux and Windows server path separators as referenced in [path.separator].
|
||||||
|
/// Instead of the [path.basename] method, which returns the last part of the path for the current client platform.
|
||||||
|
String get universalBasename {
|
||||||
|
final parts = split(RegExp(r'[\\/]+'));
|
||||||
|
return parts.where((s)=>s.isNotEmpty).lastOrNull ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ListExtensions on List<String> {
|
extension ListExtensions on List<String> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue